• Post Reply Bookmark Topic Watch Topic
  • New Topic

Update bidirectional relation without updating the objects  RSS feed

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

I have the following problem:

I have two tables

profile and profile history.

These tables have their own back reference tables to an area. (so a profile can have many areas and the history has to keep track of that)

for profile- area:
aac_profile_area_xref: profile_id(FK) and area_id(FK)

for profile_history_area:
aac_profile_his_area_xref: profile_history_id(FK) and area_id(FK).

the area has a version column so hibernate keeps track of every update:

Here is the related part of the hbm files:

for profile:

for profile history:

Now here is the sequence of events that are happening during a profile save (assuming an area is already persisted):

create a profile object.
create a profile history object.
save the history (which updates the area!)
save the profile (which tries to update the area but I get StaleObjectStateException !)

(profile and history are saved in two separate transactions)

Now what I want is a way to force hibernate to not update the area when it is saving it. i.e. just put the area_id and profile_id in the back reference table of the history.

Is there anyway to do this?


  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!