-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Question about cascading updates
PostPosted: Thu Sep 25, 2014 2:14 pm 
Beginner
Beginner

Joined: Fri Nov 14, 2008 7:11 am
Posts: 31
I have two entities "Device" and "DeviceStatus" that are mapped by a unidirectional, mandatory One-to-One relationship with CascadeType ALL. That way I can easily create and delete devices and the deviceStaus gets created and deleted accordingly. A deviceStatus cannot exist without a device.

The mapping looks like this:

Code:
public class Device {

   private Long id;
   private DeviceStatus status;

   @OneToOne(optional = false)
   @Cascade(value = { CascadeType.ALL })
   public DeviceStatus getStatus() {
   }

   public void setStatus(DeviceStatus status) {
      this.status = status;
   }

   //getter + setter for id

}


public class DeviceStatus {
   
   private Long id;
   private String statusText;

   //getter + setter
}


The problem is that the deviceStatus is updated by some background process very often. If I want to update a device by the GUI I almost always get a ConcurrentModificationException because the deviceStatus was updated between loading the device into the client and updating it back in the server.

Question is: why is Hibernate trying to update the deviceStatus as the GUI has only changed the device? I thought Hibernate would check which objects are really changed?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.