-->
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: @OneToOne and @JoinColumn, auto delete null entity , doable?
PostPosted: Sun Jan 10, 2010 2:10 pm 
Beginner
Beginner

Joined: Wed Aug 27, 2003 3:46 am
Posts: 34
Location: Taiwan
I have two Entities , with the following JPA annotations :

Code:
@Entity
@Table(name = "Owner")
public class Owner implements Serializable
{
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  @Column(name = "id")
  private long id;
 
  @OneToOne(fetch=FetchType.EAGER , cascade=CascadeType.ALL)
  @JoinColumn(name="Data_id")
  private Data Data; 
}

@Entity
@Table(name = "Data")
public class Data implements Serializable
{
  @Id
  private long id;
}


Owner and Data has one-to-one mapping , the owning side is Owner.
The problem occurs when I execute : owner.setData(null) ; ownerDao.update(owner) ;
The "Owner" table's Data_id becomes null , that's correct.

But the "Data" row is not deleted automatically.
I have to write another DataDao , and another service layer to wrap the two actions ( ownerDao.update(owner) ; dataDao.delete(data); )


Is it possible to make a data row automatically deleted when the owning Owner set it to null ?

Environment : hibernate-distribution-3.3.2.GA , hibernate-entitymanager-3.4.0.GA , JPA


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.