1+ /*
2+ * Source code generated by Celerio, a Jaxio product.
3+ * Documentation: http://www.jaxio.com/documentation/celerio/
4+ * Follow us on twitter: @jaxiosoft
5+ * Need commercial support ? Contact us: info@jaxio.com
6+ * Template pack-backend-jpa:src/main/java/domain/Entity.e.vm.java
7+ * Template is part of Open Source Project: https://github.com/jaxio/pack-backend-jpa
8+ */
9+ package demo ;
10+
11+ import com .google .common .base .MoreObjects ;
12+ import com .google .common .base .Objects ;
13+ import com .jaxio .jpa .querybyexample .Identifiable ;
14+ import org .hibernate .annotations .GenericGenerator ;
15+ import org .slf4j .Logger ;
16+ import org .slf4j .LoggerFactory ;
17+
18+ import javax .persistence .*;
19+ import java .io .Serializable ;
20+ import java .util .Date ;
21+
22+ import static javax .persistence .TemporalType .TIMESTAMP ;
23+
24+ @ Entity
25+ @ Table (name = "ACCOUNT" )
26+ public class Account implements Identifiable <String >, Serializable {
27+ private static final long serialVersionUID = 1L ;
28+ private static final Logger log = LoggerFactory .getLogger (Account .class );
29+
30+ // Raw attributes
31+ private String id ;
32+ private String username ;
33+ private Date birthDate ;
34+
35+ @ Override
36+ @ Column (name = "ID" , length = 36 )
37+ @ GeneratedValue (generator = "strategy-uuid2" )
38+ @ GenericGenerator (name = "strategy-uuid2" , strategy = "uuid2" )
39+ @ Id
40+ public String getId () {
41+ return id ;
42+ }
43+
44+ @ Override
45+ public void setId (String id ) {
46+ this .id = id ;
47+ }
48+
49+ public Account id (String id ) {
50+ setId (id );
51+ return this ;
52+ }
53+
54+ @ Override
55+ @ Transient
56+ public boolean isIdSet () {
57+ return id != null && !id .isEmpty ();
58+ }
59+
60+ // -- [username] ------------------------
61+
62+ @ Column (name = "USERNAME" , nullable = false , unique = true , length = 100 )
63+ public String getUsername () {
64+ return username ;
65+ }
66+
67+ public void setUsername (String username ) {
68+ this .username = username ;
69+ }
70+
71+ public Account username (String username ) {
72+ setUsername (username );
73+ return this ;
74+ }
75+ // -- [birthDate] ------------------------
76+
77+ @ Column (name = "BIRTH_DATE" , length = 23 )
78+ @ Temporal (TIMESTAMP )
79+ public Date getBirthDate () {
80+ return birthDate ;
81+ }
82+
83+ public void setBirthDate (Date birthDate ) {
84+ this .birthDate = birthDate ;
85+ }
86+
87+ public Account birthDate (Date birthDate ) {
88+ setBirthDate (birthDate );
89+ return this ;
90+ }
91+
92+ /**
93+ * Equals implementation using a business key.
94+ */
95+ @ Override
96+ public boolean equals (Object other ) {
97+ return this == other || (other instanceof Account && hashCode () == other .hashCode ());
98+ }
99+
100+ private volatile int previousHashCode = 0 ;
101+
102+ @ Override
103+ public int hashCode () {
104+ int hashCode = Objects .hashCode (getUsername ());
105+
106+ if (previousHashCode != 0 && previousHashCode != hashCode ) {
107+ log .warn ("DEVELOPER: hashCode has changed!." //
108+ + "If you encounter this message you should take the time to carefully review equals/hashCode for: " //
109+ + getClass ().getCanonicalName ());
110+ }
111+
112+ previousHashCode = hashCode ;
113+ return hashCode ;
114+ }
115+
116+ /**
117+ * Construct a readable string representation for this Account instance.
118+ *
119+ * @see Object#toString()
120+ */
121+ @ Override
122+ public String toString () {
123+ return MoreObjects .toStringHelper (this ) //
124+ .add ("id" , getId ()) //
125+ .add ("username" , getUsername ()) //
126+ .add ("birthDate" , getBirthDate ()) //
127+ .toString ();
128+ }
129+ }
0 commit comments