• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic