aspose file tools*
The moose likes Object Relational Mapping and the fly likes Update bidirectional relation without updating the objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Update bidirectional relation without updating the objects " Watch "Update bidirectional relation without updating the objects " New topic
Author

Update bidirectional relation without updating the objects

zabet tyan
Ranch Hand

Joined: Jan 14, 2009
Posts: 32
Hello

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?


Thanks.







 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Update bidirectional relation without updating the objects