View Javadoc
1   package myorg.relex.many2one;
2   
3   import javax.persistence.*;
4   
5   /**
6    * This class provides an example of the owning side of a many-to-one, uni-directional relationship
7    * that is realized through a foreign key from the child to the parent entity.
8    */
9   @Entity
10  @Table(name="RELATIONEX_STATERES")
11  public class StateResident {
12  	@Id @GeneratedValue
13  	private int id;
14  	
15  	@ManyToOne(
16  			optional=false, 
17  			fetch=FetchType.EAGER
18  		)
19  	@JoinColumn(
20  			name="STATE_ID"//, 
21  //			nullable=false
22  		)
23  	private State state;
24  	
25  	@Column(length=32)
26  	private String name;
27  	
28  	protected StateResident() {}
29  	public StateResident(State state) {
30  		this.state = state;
31  	}
32  
33  	public int getId() { return id; }
34  
35  	public State getState() { return state; }
36  	public void setState(State state) {
37  		this.state = state;
38  	}
39  	
40  	public String getName() { return name; }
41  	public void setName(String name) {
42  		this.name = name;
43  	}
44  }