These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: problem with references in map collection
PostPosted: Tue Nov 01, 2005 10:46 am 
Newbie

Joined: Wed Oct 19, 2005 11:21 am
Posts: 1
Location: Amsterdam
hi all,

I have a problem with the mapping of a map collection and it is driving me crazy. See the details below:

Hibernate version:
3.0

Mapping documents:

<class name="nl.masla.smodel.data.Student" table="student">
<id name="sid" column="sid">
</id>
<property name="uname"/>
<property name="firstname" />
<property name="lastname"/>
<map name="testResults" table="testresults">
<key column="sid" not-null="true"/>
<map-key-many-to-many column="tid" class="nl.masla.test.data.Test"/>
<many-to-many column="trid" class="nl.masla.smodel.data.TestResult"/>
</map>
</class>

<class name="nl.masla.smodel.data.TestResult" table="testresult">
<id name="trid" column="trid">
<generator class="increment"/>
</id>
<many-to-one name="test" column="tid" class="nl.masla.test.data.Test"/>
<map name="itemResults" table="itemresults">
<key column="trid" not-null="true"/>
<map-key-many-to-many column="iid" class="nl.masla.test.data.Item"/>
<many-to-many column="irid" class="nl.masla.smodel.data.ItemResult"/>
</map>
</class>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

2005-11-01 15:13:10,172 [http-8080-Processor24] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - dirty checking collections
2005-11-01 15:13:10,172 [http-8080-Processor24] DEBUG org.hibernate.engine.CollectionEntry - Collection dirty: [nl.masla.smodel.data.Student.testResults#7]
2005-11-01 15:13:10,172 [http-8080-Processor24] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushing entities and processing referenced collections
2005-11-01 15:13:10,172 [http-8080-Processor24] DEBUG org.hibernate.engine.Collections - Collection found: [nl.masla.smodel.data.Student.testResults#7], was: [nl.masla.smodel.data.Student.testResults#7] (initialized)
2005-11-01 15:13:10,172 [http-8080-Processor24] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Processing unreferenced collections
2005-11-01 15:13:10,172 [http-8080-Processor24] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Scheduling collection removes/(re)creates/updates
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - Flushed: 0 (re)creations, 1 updates, 0 removals to 1 collections
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.pretty.Printer - listing entities:
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.pretty.Printer - nl.masla.smodel.data.Student{lastname=null, sid=7, testResults=[nl.masla.smodel.data.TestResult#4], firstname=null, uname=r}
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.event.def.AbstractFlushingEventListener - executing flush
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.persister.collection.AbstractCollectionPersister - Deleting rows of collection: [nl.masla.smodel.data.Student.testResults#7]
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.persister.collection.AbstractCollectionPersister - no rows to delete
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.persister.collection.AbstractCollectionPersister - Updating rows of collection: nl.masla.smodel.data.Student.testResults#7
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.persister.collection.AbstractCollectionPersister - done updating rows: 0 updated
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.persister.collection.AbstractCollectionPersister - Inserting rows of collection: [nl.masla.smodel.data.Student.testResults#7]
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.jdbc.AbstractBatcher - preparing statement
2005-11-01 15:13:10,182 [http-8080-Processor24] DEBUG org.hibernate.type.LongType - binding '7' to parameter: 1
2005-11-01 15:13:10,182 [http-8080-Processor24] ERROR org.hibernate.property.BasicPropertyAccessor - IllegalArgumentException in class: nl.masla.test.data.Test, getter method of property: tid
2005-11-01 15:13:10,182 [http-8080-Processor24] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of nl.masla.test.data.Test.tid
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.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:215)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:99)
at org.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:63)
at org.hibernate.persister.collection.AbstractCollectionPersister.writeIndex(AbstractCollectionPersister.java:665)
at org.hibernate.persister.collection.AbstractCollectionPersister.insertRows(AbstractCollectionPersister.java:1068)
at org.hibernate.action.CollectionUpdateAction.execute(CollectionUpdateAction.java:48)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at nl.masla.util.HibernateTemplate.execute(HibernateTemplate.java:37)
at nl.masla.smodel.ModelManager.updateStudent(ModelManager.java:69)
at nl.masla.servlets.ShowTest.registerAnswer(ShowTest.java:128)
at nl.masla.servlets.ShowTest.process(ShowTest.java:78)
at nl.masla.servlets.ShowTest.doPost(ShowTest.java:57)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
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:105)
... 49 more

Name and version of the database you are using:

MySQL

Problem:

The problem occurs when I update the Student class and there is an entry in the map. I have created the testresults table for the map (with sid, tid, trid as the primary key) but for some reason it wont add the entry to this table. Both the Test and the TestResult are already persistent and the association is correct.

Any suggestions would be greatly appreciated. Let me know if more info is needed.

regards,

Rintse


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.