Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Avoid StaleObjectStateException in hibernate for bidirectional relation

Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have the following problem:

I have a class Group

and a class Profile:

Here is the related section of hbm file for Group

and for Profile:

Now I want to add a group to profile and add the profile to that group:

The problem is that I can never update the bi-direlational relation because I get StaleObjectException as soon as I try to update the second part of the relation.

Any suggestions on what I can do to avoid this problem without breaking the relation?

Do I have to load the Profile again from the database before I add the Profile to Group and save?

Any help is appreciated.
zabet tyan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK solved it... just had to remove cascade="all" from Group.hbm.xml

Hey cool! They got a blimp! But I have a tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic