ecornely

Untitled

Jun 17th, 2015
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.47 KB | None | 0 0
  1. package demo;
  2.  
  3. import java.io.Serializable;
  4.  
  5. import javax.persistence.CascadeType;
  6. import javax.persistence.Column;
  7. import javax.persistence.Entity;
  8. import javax.persistence.GeneratedValue;
  9. import javax.persistence.GenerationType;
  10. import javax.persistence.Id;
  11. import javax.persistence.JoinColumn;
  12. import javax.persistence.OneToOne;
  13.  
  14. @Entity
  15. public class Person implements Serializable {
  16.     private static final long serialVersionUID = 5646406319890858241L;
  17.     @Id
  18.     @GeneratedValue(strategy=GenerationType.IDENTITY)
  19.     private Long id;
  20.     @Column
  21.     private String firstName;
  22.     @Column
  23.     private String lastName;
  24.     @OneToOne(targetEntity=PersonBiography.class, cascade={CascadeType.ALL})
  25.     @JoinColumn(name="bio_name", referencedColumnName="name")
  26.     private PersonBiography biography;
  27.    
  28.     public Long getId() {
  29.         return id;
  30.     }
  31.     public void setId(Long id) {
  32.         this.id = id;
  33.     }
  34.     public String getFirstName() {
  35.         return firstName;
  36.     }
  37.     public void setFirstName(String firstName) {
  38.         this.firstName = firstName;
  39.     }
  40.     public String getLastName() {
  41.         return lastName;
  42.     }
  43.     public void setLastName(String lastName) {
  44.         this.lastName = lastName;
  45.     }
  46.    
  47.     public PersonBiography getBiography() {
  48.         return biography;
  49.     }
  50.     public void setBiography(PersonBiography biography) {
  51.         this.biography = biography;
  52.     }
  53.     @Override
  54.     public String toString() {
  55.         return "Person [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", biography=" + biography
  56.                 + "]";
  57.     }
  58.    
  59.    
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment