-->
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: Delete entity: ignoring version change
PostPosted: Wed Nov 17, 2010 9:52 am 
Beginner
Beginner

Joined: Fri Nov 14, 2008 7:11 am
Posts: 31
Hi,

we have to classes Person and Address which have a bidirectional One-To-One relation (optional = false).

Code:
public class Person {
       private Address address;

   @OneToOne(optional = false)
   public Address getAddress() {
      return address;
   }
}

public class Address {
       private Person person;

   @OneToOne(optional = false, mappedBy = "address")
   public Person getPerson() {
      return person;
   }
}


A persons Address might change very often in our application. Of course we want user A to be informed by Hibernate that another user has changed an address when A tries to change the same address. Therefore we use a version column and optimistic locking.

Nevertheless when A tries to delete a person it should be allowed no matter whether his address has changed since last read or not. In other words we want to ignore the version number of the persons address when deleting this person.

How would you do this in Hibernate?

Thanks in advance,
Ole


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.