Hi,
I have a problem occurring only with this special mapping configuration. Both entitys are stored in the database, only the connecting relation is not stored. Any help is highly appreciated as this problem exists since last week... If you need further information please ask for it.
Thanks in advance!
Matthias
Information on class hierarchy:
Item extends AbstractItem(generated by hibernate) extends BasePojo(implements methods save() and find())
Hibernate version: 3.0.5
Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="de.lmr.mcg.persistant.pojos.Item" table="item">
<meta attribute="generated-class">
de.lmr.mcg.persistant.pojos.AbstractItem
</meta>
<meta attribute="scope-class">public abstract</meta>
<meta attribute="extends" inherit="true">BasePojo</meta>
<id name="id" type="java.lang.Integer" column="ITEM_ID">
<meta attribute="scope-set">public</meta>
<generator class="native" />
</id>
<property name="name" type="string">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
<column name="NAME" not-null="true" />
</property>
<list name="itemsAudioSets" table="items_audio_sets" lazy="false"
cascade="save-update,persist" inverse="false">
<meta attribute="scope-set">protected</meta>
<meta attribute="scope-get">protected</meta>
<key column="AUDIOSET_ID" />
<index column="POSITION" />
<one-to-many class="de.lmr.mcg.persistant.pojos.Item" />
</list>
</class>
<class name="de.lmr.mcg.persistant.pojos.AudioSet"
table="audio_set">
<meta attribute="generated-class">
de.lmr.mcg.persistant.pojos.AbstractAudioSet
</meta>
<meta attribute="scope-class">public abstract</meta>
<meta attribute="extends" inherit="true">BasePojo</meta>
<id name="id" type="java.lang.Integer" column="AUDIOSET_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native" />
</id>
<property name="name" type="string" column="name">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
</property>
<property name="description" type="string" column="description">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
</property>
<property name="length" type="int" column="length" />
<list name="itemsAudioSets" table="items_audio_sets" lazy="false"
cascade="save-update,persist" inverse="false">
<meta attribute="scope-set">protected</meta>
<meta attribute="scope-get">protected</meta>
<key column="AUDIOSET_ID" />
<index column="POSITION" />
<one-to-many class="de.lmr.mcg.persistant.pojos.Item" />
</list>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public void save(){
Session session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();
session.saveOrUpdate(this);
tx.commit();
HibernateUtil.closeSession();
}
Full stack trace of any exception that occurs:
16.06.2006 11:39:11 org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
16.06.2006 11:39:11 org.hibernate.impl.SessionFactoryImpl checkNamedQueries
INFO: Checking 0 named queries
16.06.2006 11:39:12 org.hibernate.property.BasicPropertyAccessor$BasicGetter get
SCHWERWIEGEND: IllegalArgumentException in class: de.lmr.mcg.persistant.pojos.AbstractItem, getter method of property: id
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of de.lmr.mcg.persistant.pojos.AbstractItem.id
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:119)
at org.hibernate.tuple.AbstractTuplizer.getIdentifier(AbstractTuplizer.java:103)
at org.hibernate.persister.entity.BasicEntityPersister.getIdentifier(BasicEntityPersister.java:2944)
at org.hibernate.persister.entity.BasicEntityPersister.isTransient(BasicEntityPersister.java:2705)
at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:181)
at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:409)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:82)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.engine.Cascades$5.cascade(Cascades.java:154)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:771)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascadeCollection(Cascades.java:895)
at org.hibernate.engine.Cascades.cascadeAssociation(Cascades.java:792)
at org.hibernate.engine.Cascades.cascade(Cascades.java:720)
at org.hibernate.engine.Cascades.cascade(Cascades.java:847)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:363)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:160)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:95)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:96)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:468)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:463)
at de.lmr.mcg.persistant.pojos.BasePojo.save(BasePojo.java:35)
at de.lmr.mcg.persistant.pojos.ItemTest.testItemInsert(ItemTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:105)
... 42 more
16.06.2006 11:39:12 org.hibernate.property.BasicPropertyAccessor$BasicGetter get
SCHWERWIEGEND: IllegalArgumentException in class: de.lmr.mcg.persistant.pojos.AbstractItem, getter method of property: id
Name and version of the database you are using:
MySQL 5.0.18
The generated SQL (show_sql=true):
Hibernate: insert into audio_set (name, description, length, IMAGE_ID) values (?, ?, ?, ?)
Hibernate: select this_.AUDIOSET_ID as AUDIOSET1_0_, this_.name as name5_0_, this_.description as descript3_5_0_, this_.length as length5_0_, this_.IMAGE_ID as IMAGE5_5_0_ from audio_set this_ where this_.name=?
Hibernate: select itemsaudio0_.AUDIOSET_ID as AUDIOSET3_1_, itemsaudio0_.ITEM_ID as ITEM1_1_, itemsaudio0_.POSITION as POSITION1_, itemsaudio0_.ITEM_ID as ITEM1_0_, itemsaudio0_.NAME as NAME13_0_ from item itemsaudio0_ where itemsaudio0_.AUDIOSET_ID=?
Hibernate: select audioinfos0_.AUDIOSET_ID as AUDIOSET2_1_, audioinfos0_.AUDIOINFO_ID as AUDIOINFO1_1_, audioinfo1_.AUDIOINFO_ID as AUDIOINFO1_0_, audioinfo1_.description as descript2_3_0_, audioinfo1_.filename as filename3_0_ from audio_sets_audio_infos audioinfos0_ inner join audio_info audioinfo1_ on audioinfos0_.AUDIOINFO_ID=audioinfo1_.AUDIOINFO_ID where audioinfos0_.AUDIOSET_ID=?
Hibernate: insert into item (NAME) values (?)
|