]> SALOME platform Git repositories - modules/gde.git/blob - projects/GDE_App/GDE-ejb/src/java/com/edf/gde/entities/Attribute.java
Salome HOME
Define Code skeleton
[modules/gde.git] / projects / GDE_App / GDE-ejb / src / java / com / edf / gde / entities / Attribute.java
1 /*
2  * To change this license header, choose License Headers in Project Properties.
3  * To change this template file, choose Tools | Templates
4  * and open the template in the editor.
5  */
6 package com.edf.gde.entities;
7
8 import java.io.Serializable;
9 import java.util.Objects;
10 import javax.persistence.Basic;
11 import javax.persistence.Column;
12 import javax.persistence.Entity;
13 import javax.persistence.GeneratedValue;
14 import javax.persistence.GenerationType;
15 import javax.persistence.Id;
16 import javax.persistence.JoinColumn;
17 import javax.persistence.ManyToOne;
18 import javax.persistence.NamedQueries;
19 import javax.persistence.NamedQuery;
20 import javax.persistence.SequenceGenerator;
21 import javax.persistence.Table;
22 import javax.validation.constraints.NotNull;
23 import javax.validation.constraints.Size;
24 import javax.xml.bind.annotation.XmlRootElement;
25
26 /**
27  *
28  * @author F62173
29  */
30 @Entity
31 @Table(name = "attribute")
32 @XmlRootElement
33 @NamedQueries({
34     @NamedQuery(name = "Attribute.findAll", query = "SELECT a FROM Attribute a"),
35     @NamedQuery(name = "Attribute.findById", query = "SELECT a FROM Attribute a WHERE a.id = :id"),
36     @NamedQuery(name = "Attribute.findByName", query = "SELECT a FROM Attribute a WHERE a.name = :name"),
37     @NamedQuery(name = "Attribute.findByType", query = "SELECT a FROM Attribute a WHERE a.type = :type"),
38     @NamedQuery(name = "Attribute.findByValue", query = "SELECT a FROM Attribute a WHERE a.value = :value"),
39     //@NamedQuery(name = "Attribute.findByMandatory", query = "SELECT a FROM Attribute a WHERE a.mandatory = :mandatory")
40 })
41 public class Attribute implements Serializable {
42     private static final long serialVersionUID = 1L;
43     @Id
44     @Basic(optional = false)
45     @NotNull
46     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
47     @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
48     @Column(name = "id")
49     private long id;
50     @Size(max = 255)
51     @Column(name = "name")
52     private String name;
53     @Size(max = 255)
54     @Column(name = "type")
55     private String type;
56     @Size(max = 255)
57     @Column(name = "value")
58     private String value;
59     @Column(name = "mandatory")
60     private Boolean mandatory;
61     @JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false)
62     @ManyToOne
63     private AttributeGroup groupId;
64
65     public Attribute() {
66     }
67
68     public Attribute(long id) {
69         this.id = id;
70     }
71
72     public long getId() {
73         return id;
74     }
75
76     public void setId(long id) {
77         this.id = id;
78     }
79
80     public String getName() {
81         return name;
82     }
83
84     public void setName(String name) {
85         this.name = name;
86     }
87
88     public String getType() {
89         return type;
90     }
91
92     public void setType(String type) {
93         this.type = type;
94     }
95
96     public String getValue() {
97         return value;
98     }
99
100     public void setValue(String value) {
101         this.value = value;
102     }
103
104     public Boolean getMandatory() {
105         return mandatory;
106     }
107
108     public void setMandatory(Boolean mandatory) {
109         this.mandatory = mandatory;
110     }
111
112     public AttributeGroup getGroupId() {
113         return groupId;
114     }
115
116     public void setGroupId(AttributeGroup groupId) {
117         this.groupId = groupId;
118     }
119
120     @Override
121     public String toString() {
122         return "com.edf.gde.entities.Attribute[ id=" + id + " ]";
123     }
124
125     @Override
126     public int hashCode() {
127         int hash = 5;
128         hash = 29 * hash + (int) (this.id ^ (this.id >>> 32));
129         hash = 29 * hash + Objects.hashCode(this.name);
130         hash = 29 * hash + Objects.hashCode(this.type);
131         hash = 29 * hash + Objects.hashCode(this.value);
132         hash = 29 * hash + Objects.hashCode(this.mandatory);
133         hash = 29 * hash + Objects.hashCode(this.groupId);
134         return hash;
135     }
136
137     @Override
138     public boolean equals(Object obj) {
139         if (obj == null) {
140             return false;
141         }
142         if (getClass() != obj.getClass()) {
143             return false;
144         }
145         final Attribute other = (Attribute) obj;
146         if (this.id != other.id) {
147             return false;
148         }
149         return true;
150     }
151     
152 }