View Javadoc
1   package myorg.relex.one2one;
2   
3   import javax.persistence.*;
4   
5   /**
6    * This entity class provides an example of a dependent with a relationship to a parent entity that
7    * should only exist to support this entity. When this entity ceases to reference the parent, it 
8    * will become "orphaned" and subject to orphanRemoval by the provider.
9    */
10  @Entity
11  @Table(name="RELATIONEX_ATTENDEE")
12  public class Attendee {
13      @Id @GeneratedValue
14      private int id;
15      
16      //orphanRemoval will take care of dereference and DELETE from dependent Attendee 
17      @OneToOne(cascade=CascadeType.PERSIST, orphanRemoval=true)
18      private Residence residence;
19      
20      private String name;
21  
22  	public int getId() { return id; }
23  
24  	public Residence getResidence() { return residence; }
25  	public void setResidence(Residence residence) {
26  		this.residence = residence;
27  	}
28  
29  	public String getName() { return name; }
30  	public void setName(String name) {
31  		this.name = name;
32  	}
33  }