I have read several tutorial concerning the for hibernate. I’m still getting confusion. Does the generator changes in case of associations. Can someone explain well according to their experience that worked how to use this because this is the source of all my problems such as violations.
I have read several tutorial concerning the for hibernate. I’m still getting confusion. Does
Share
If I understand your question correctly, you are asking, what are generators and how are they used with associations?
The first answer is easy: Generators define a strategy for assigning ids to objects.
The second answer is: depends on how you set up your relationships. For example look at the documentation for a unique one-to-one based on primary key
http://docs.jboss.org/hibernate/core/3.5/reference/en/html/mapping.html#mapping-declaration-onetoone
here the generator class of one side is set to ‘foreign’, which is a special case because two tables are sharing the same id.
Note the other one-to-one example, in that case no generator is assigned on one side of the relationship.
If you are having issues with persistence I suggest the following 2 items