-->
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.  [ 2 posts ] 
Author Message
 Post subject: @ManyToOne - delete value in column
PostPosted: Thu Mar 27, 2008 9:06 am 
Newbie

Joined: Thu Mar 27, 2008 8:54 am
Posts: 1
hi

this is part of my User class:
////////////////////
Code:
@Entity
@Table(name = "xxx.yyy.[User]")
@org.hibernate.annotations.Entity(mutable = true)
@BatchSize(size = 50)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class User {

..

    private Cluster cluster;

..

   @ManyToOne(fetch=FetchType.LAZY)
        @JoinColumn(name="clusterId")
        @LazyToOne(LazyToOneOption.PROXY)
   public Cluster getCluster() {
      return cluster;
   }

   public void setCluster(Cluster cluster) {
      this.cluster = cluster;
   }

///////////////////////
this User is represented in the 'User' table in the database
the clusterId column is an int, nullable

when i delete a certain 'cluster' in my application
the value in the 'clusterId' column is not removed in 'User' table
it should be put to NULL

can anybody point me to a solution ?

thanks for your time
sc3*2


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 28, 2008 3:27 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
If your database is setup correctly (with the proper constraints) you should not be able to delete a cluster while a FK to one cluster row exists (perhaps the constraints are missing).

That said, deleting a cluster and breaking the association are two different things in JPA, just as they are relationally. You need to do user.setCluster(null) to null out the association.

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


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

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.