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.