View Javadoc
1   package myorg.relex.one2one;
2   
3   import java.util.Date;
4   import javax.persistence.*;
5   
6   /**
7    * This entity class provides an example of cascades being originated from
8    * the inverse side of a bi-directional relationship.
9    */
10  @Entity
11  @Table(name="RELATIONEX_TICKET")
12  public class Ticket {
13  	@Id @GeneratedValue
14  	private int id;
15  	
16  	@OneToOne(mappedBy="ticket", fetch=FetchType.EAGER,
17  			cascade={
18  			CascadeType.PERSIST,
19  			CascadeType.DETACH,
20  			CascadeType.REFRESH,
21   		    CascadeType.MERGE,
22  			CascadeType.REMOVE
23  		})
24  	private Passenger passenger;
25  	
26  	@Temporal(TemporalType.DATE)
27  	Date date;
28  
29  	public Ticket(){}
30  	public Ticket(int id) { this.id = id; }
31  	public int getId() { return id; }
32  
33  	public Passenger getPassenger() { return passenger; }
34  	public void setPassenger(Passenger passenger) {
35  		this.passenger = passenger;
36  	}
37  
38  	public Date getDate() { return date; }
39  	public void setDate(Date date) {
40  		this.date = date;
41  	}	
42  }