-->
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.  [ 3 posts ] 
Author Message
 Post subject: My collections are recreated in the DB (m-to-n mapping)
PostPosted: Sun Nov 16, 2003 10:59 am 
Beginner
Beginner

Joined: Wed Oct 15, 2003 3:08 pm
Posts: 32
First, I know this is similar to a couple FAQ items. Of course, that doesn't mean I haven't done something stupid :).

Basically, I have a m to n mapping between a Group and System domain object. The mapping includes an additional attribute, which is State.

Every time I pull back the Set (Group- State for System, or System - State for Group) and later flush, it appears that hibernate is deleting the collection and rebuilding it.

I see these log entries:

Code:
08:42:33,889 DEBUG BatcherImpl:166 - about to open: 0 open PreparedStatements, 0 open ResultSets
08:42:33,889 DEBUG SessionFactoryImpl:526 - prepared statement get: delete from group_systemlist where system_id=? and state=? and group_id=?
08:42:33,889 DEBUG SessionFactoryImpl:536 - preparing statement
08:42:33,899 DEBUG CollectionPersister:676 - done deleting collection rows
08:42:33,899 DEBUG CollectionPersister:755 - Updating rows of collection: xxx.domain.SystemDO.groupStates#40288183f8e4c7b800f8e4c7bc7600ab
08:42:33,899 DEBUG CollectionPersister:765 - done updating rows
08:42:33,899 DEBUG CollectionPersister:774 - Inserting rows of collection: xxx.server.domain.SystemDO.groupStates#40288183f8e4c7b800f8e4c7bc7600ab
08:42:33,899 DEBUG BatcherImpl:173 - done closing: 0 open PreparedStatements, 0 open ResultSets
08:42:33,899 DEBUG SessionFactoryImpl:554 - closing statement


I did a check of the logs and did not find any "isdirty" or "dirty" log entries.

Now, my domain object is simple for these Sets. The only time I touch the set is during construction and in the Hibernate setter. The only thing calling the setter is Hibernate. I set the Set to a new HashSet during construction to handle cases when this is a transient object not yet persisted in Hibernate.

Any insight would be greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 16, 2003 11:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Nowhere near enough information.

We would need at least all the mappings and java code.

But it doesn't look to me like Hibernate is deleting the collection and rebuilding it. Looks more like it is just deleting a couple of elements that were removed.

"removed" can sometimes mean that the element did not implememt equals()/hashCode() correctly, or you did something to change the hashCode() after adding it to the set.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 16, 2003 11:09 am 
Beginner
Beginner

Joined: Wed Oct 15, 2003 3:08 pm
Posts: 32
I think your post got me thinking in the right direction Gavin. I figured it was something rediculously simple. Anyway, I forgot to implement equals()/hashCode() on the objects contained in the Set. Thank you for the help!


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

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.