-->
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.  [ 2 posts ] 
Author Message
 Post subject: Same object being loaded from cache for every instance...
PostPosted: Fri Sep 05, 2003 8:29 pm 
Senior
Senior

Joined: Sun Aug 31, 2003 3:14 pm
Posts: 151
Location: Earth (at the moment)
I've got my mappings all working with one exception, I've got a class that I think I haven't mapped correctly because every record read from the database gets equated to one object already in the cache when they don't really equal one another.

I think I need a UserType, so I wrote one, but where/how do you specify it when using a <one-to-many .../> mapping?

Should I instead try to make a UserType for the key? I assume that the objects are being considered equal because I only mapped the <id> to one column which isn't unique?

My table is like this:
Code:
my_table { foreign_id INT, my_id INT, my_code CHAR(2), my_data VARCHAR(50) }

and the primary key is composed of foreign_id, my_id, and my_code.

My simple mapping with one field as the key was enough to get it running and get the right count of records from the database but not enough to actually get distinct objects and so every record read from the database is perceived to be the one object already in the cache (I've read through the debugging trace from Hibernate).

I think this is similar to question http://forum.hibernate.org/viewtopic.php?t=248 but I also need more information on how to write a UserType that is the key. I may just be looking in the wrong places or unable to find an example if one exists so could someone please point me to a comprehensive example on writing a UserType for the key or post one here?

Thank-you very much.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2003 9:34 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Why would you not just use a standard <composite-id> mapping?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.