Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class lazy="false"
optimistic-lock="version"
dynamic-update="true"
name="de.bitmanager.fairtracks.xmlimport.vo.Track" table="track" node="track"
entity-name="track">
<id name="id" type="int" unsaved-value="-1" node="@id">
<column name="id" sql-type="int" not-null="true"/>
<generator class="native">
<param name="sequence">sq_track</param>
</generator>
</id>
<version name="version" unsaved-value="negative"/>
<!-- <many-to-one name="album" node="album"/>
<many-to-one name="trackState" column="track_state" node="trackState" class="de.bitmanager.fairtracks.xmlimport.vo.TrackState"/>
-->
<property name="name" node="name" />
<property name="url" node="url"/>
<property name="skipUrl" node="skipUrl"/>
<property name="rating" node="rating"/>
<property name="creationDate" node="creationDate"/>
<property name="albumPosition" node="albumPosition"/>
<property name="referenceTrack" node="referenceTrack"/>
<property name="tracklen" node="tracklen"/>
<property name="isrc" node="isrc"/>
<property name="trackArtist" node="trackArtist"/>
<property name="trackTexter" node="trackTexter"/>
<property name="trackComposer" node="trackComposer"/>
<property name="trackProducer" node="trackProducer"/>
<property name="setNumber" node="setNumber"/>
<property name="publishingInfo" node="publishingInfo"/>
<property name="updateTime" column="update_time" not-null="true"/>
<property name="updateUser" column="update_user" not-null="true"/>
<property name="tenantId" column="tenant_id" not-null="true"/>
<filter
name="tenantFilter"
condition=":tenantId = tenant_id" />
</class>
<filter-def name="tenantFilter">
<filter-param name="tenantId" type="integer"/>
</filter-def>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
SAXReader reader = new SAXReader();
try {
Document doc = reader.read(new File(path));
Element root = doc.getRootElement();
Element track = root.element("track");
Session s;
try {
s = this.getBase().openSession();
Transaction t = s.beginTransaction();
s.persist( "track", track );
t.commit();
s.close();
System.out.println(">>> Gespeichert!");
} catch (ORException e) {
e.printStackTrace();
}
} catch (DocumentException e) {
e.printStackTrace();
}
Full stack trace of any exception that occurs:
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of de.bitmanager.fairtracks.xmlimport.vo.StandardValue.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:171)
at org.hibernate.tuple.AbstractEntityTuplizer.getIdentifier(AbstractEntityTuplizer.java:176)
at org.hibernate.persister.entity.AbstractEntityPersister.getIdentifier(AbstractEntityPersister.java:3257)
at org.hibernate.persister.entity.AbstractEntityPersister.isTransient(AbstractEntityPersister.java:2983)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:460)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:70)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:640)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:614)
at de.bitmanager.fairtracks.xmlimport.service.impl.TrackImportServiceImpl.readXML(TrackImportServiceImpl.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invoke(StatefulSessionContainer.java:584)
at org.jboss.ejb.plugins.StatefulHASessionSynchronisationInterceptor.invoke(StatefulHASessionSynchronisationInterceptor.java:93)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:153)
at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invoke(StatefulSessionInstanceInterceptor.java:315)
at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.CleanShutdownInterceptor.invoke(CleanShutdownInterceptor.java:264)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:873)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:245)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.invocation.jrmp.server.JRMPInvokerHA.invoke(JRMPInvokerHA.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
at sun.rmi.transport.Transport$1.run(Transport.java:148)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:145)
... 50 more
Name and version of the database you are using:
Oracle
XML-Document:
<?xml version="1.0" encoding="UTF-8"?>
<tracks>
<track id="1412">
<version>3</version>
<name>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX (Out Goes The Light)</name>
<url>The_Animals_feat_Eric_Burdon_-_Boom_Boom_(Out_Goes_The_Light)12.mp3</url>
<skipUrl>skip_The_Animals_feat_Eric_Burdon_-_Boom_Boom_(Out_Goes_The_Light)12.mp3</skipUrl>
<creationDate>2006-03-28 13:33:42</creationDate>
<albumPosition>12</albumPosition>
<referenceTrack>false</referenceTrack>
<tracklen>196</tracklen>
<isrc>DE-A37-05-04301</isrc>
<trackArtist>The Animals feat. Eric Burdon</trackArtist>
<trackTexter>John Lee Hooker</trackTexter>
<trackComposer>John Lee Hooker</trackComposer>
<setNumber>1</setNumber>
<publishingInfo>Conrad Music Inc., ARC Music Corp., Coachman Edition</publishingInfo>
<updateTime>2006-03-30 15:29:59</updateTime>
<updateUser>bierg</updateUser>
<tenantId>1</tenantId>
</track>
</tracks>
Hi, I'm trying to save an Entity "Track" via XML-Import and Hibernate Mapping. I get the error mentioned above. My id variable is of the type int.
Please Help!
Jan