• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

[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

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
    Bookmark Topic Watch Topic
  • New Topic