Blame view

src/main/java/fr/plil/sio/examen/api/Animal.java 1.16 KB
589e1ad3   jcartign   First version
1
2
3
4
5
6
7
8
  package fr.plil.sio.examen.api;

  

  import java.io.Serializable;

  import javax.persistence.Column;

  import javax.persistence.Entity;

  import javax.persistence.GeneratedValue;

  import javax.persistence.GenerationType;

  import javax.persistence.Id;

069a0012   rvangrev   Annotations ajoutées
9
  import javax.persistence.JoinColumn;

589e1ad3   jcartign   First version
10
  import javax.persistence.ManyToOne;

069a0012   rvangrev   Annotations ajoutées
11
  import javax.persistence.Table;

589e1ad3   jcartign   First version
12
13
14
15
16
  

  /**

   * An animal must have a name one and only one owner

   */

  @Entity

069a0012   rvangrev   Annotations ajoutées
17
  @Table(name="ANIMAL_T")

589e1ad3   jcartign   First version
18
19
20
21
22
23
  public class Animal implements Serializable {

      

      @Id

      @GeneratedValue(strategy = GenerationType.AUTO)

      private Long id;

      

069a0012   rvangrev   Annotations ajoutées
24
      @Column(name="NAME_A",nullable = false)

589e1ad3   jcartign   First version
25
26
27
      private String name;

  

      @ManyToOne(optional = false)

069a0012   rvangrev   Annotations ajoutées
28
      @JoinColumn(name="OWNER_ID")

589e1ad3   jcartign   First version
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
      private Owner owner;

      

      public Long getId() {

          return id;

      }

  

      public void setId(Long id) {

          this.id = id;

      }

  

      public String getName() {

          return name;

      }

  

      public void setName(String name) {

          this.name = name;

      }

  

      public Owner getOwner() {

          return owner;

      }

  

      public void setOwner(Owner owner) {

          this.owner = owner;

      }

      

      

  }