Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does hibernate handle IDs when persisting parent adn its children?

 
Sonx Nkuks
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i'm having a parent to children mapping with a link table



if i use session.saveOrUpdate(batchOverrideDo) without having set the overrideId and all the children IDs (all null), will hibernate take care of that or should i at least set the children IDs to a value? TaskOverride and OverrideItem are my two link tables for my children
 
Bogdan Baraila
Ranch Hand
Posts: 43
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
If your OverrideID is an identity column (autonumber, sequence etc.) than it should work else it will not cause this is what is using the identity generator class.
 
Sonx Nkuks
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bogdan Baraila wrote:Hello.
If your OverrideID is an identity column (autonumber, sequence etc.) than it should work else it will not cause this is what is using the identity generator class.


Thanks Bogdan, was also more worried about the children's ID (ItemID) ....
 
Bogdan Baraila
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As long as the children id's are also mapped to a identity column you don't have any reasons to worry. If you add a new children to a parent object and save the parent the children will be saved also, with the setting you have now.
 
Sonx Nkuks
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bogdan Baraila wrote:As long as the children id's are also mapped to a identity column you don't have any reasons to worry. If you add a new children to a parent object and save the parent the children will be saved also, with the setting you have now.


Alright thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic