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

[Hibernate] managing multiple detached objects that represent the same database row

 
jan dressen
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

Suppose I have class Parent and a class Child



First I retrieve a Parent from the database with all its children.
I close my session, so now I have 1 Parent with all its children as detached objects.

I now start a second session and only retrieve 1 child. But that child's parent is the same parent I retrived from the first session. So that child is also in the list of children I got from my first DB transaction.

But the problem is: they are both different java instances. So if I change the parent object I got from the first transaction, or I change the child from the second transaction, then I have 2 objects that represent the same row in DB but with different values.

Is there a way to solve/manage these kind of things?

thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic