1 package net
.aramzamzam
.commons
.hibernate
.entities
;
3 import java
.io
.Serializable
;
5 import javax
.persistence
.GeneratedValue
;
6 import javax
.persistence
.GenerationType
;
7 import javax
.persistence
.Id
;
8 import javax
.persistence
.MappedSuperclass
;
11 * @author James Carman
13 @SuppressWarnings("unchecked")
15 public class BasicEntity
implements Serializable
, Comparable
{
16 private static final long serialVersionUID
= 1L;
19 public int compareTo(Object o
) {
20 return String
.valueOf(this).compareTo(String
.valueOf(o
));
24 @GeneratedValue(strategy
= GenerationType
.AUTO
)
29 // FIXME доступ к этому методу следует сделать private
30 public void setId(Long id
) {
35 public int hashCode() {
38 result
= prime
* result
+ ((id
== null) ?
0 : id
.hashCode());
41 //see http://roald.jteam.nl/?p=25
43 public boolean equals(Object obj
) {
48 getClass() == obj
.getClass()
49 || getClass().getSuperclass() == obj
.getClass().getSuperclass()
50 || getClass() == obj
.getClass().getSuperclass()
51 || getClass().getSuperclass() == obj
.getClass()
54 final BasicEntity other
= (BasicEntity
) obj
;
55 if (id
!= null ?
!id
.equals(other
.getId()) : other
.getId() != null)