1 package org.hibernate.ce.auction.model; 2 3 import javax.persistence.*; 4 import java.io.Serializable ; 5 import java.util.Date ; 6 7 17 @Entity(access = AccessType.FIELD) 18 @Table(name = "BILLING_DETAILS") 19 @Inheritance(strategy = InheritanceType.JOINED) 20 public abstract class BillingDetails implements Serializable , Comparable { 21 22 @Id(generate = GeneratorType.AUTO) 23 @Column(name = "BILLING_DETAILS_ID") 24 private Long id = null; 25 26 @Version 27 private int version = 0; 28 29 @Column(name = "OWNER_NAME", nullable = false) 30 private String ownerName; 31 32 @ManyToOne 33 @JoinColumn(name = "USER_ID", updatable = false) 34 private User user; 35 36 @Column( nullable = false, updatable = false) 37 private Date created = new Date (); 38 39 42 BillingDetails() {} 43 44 47 protected BillingDetails(String ownerName, User user) { 48 this.ownerName = ownerName; 49 this.user = user; 50 } 51 52 54 public Long getId() { return id; } 55 public int getVersion() { return version; } 56 57 public String getOwnerName() { return ownerName; } 58 public void setOwnerName(String ownerName) { this.ownerName = ownerName; } 59 60 public User getUser() { return user; } 61 62 public Date getCreated() { return created; } 63 64 66 public boolean equals(Object o) { 67 if (this == o) return true; 68 if (!(o instanceof BillingDetails)) return false; 69 70 final BillingDetails billingDetails = (BillingDetails) o; 71 72 if (!getCreated().equals(billingDetails.getCreated())) return false; 73 if (!getOwnerName().equals(billingDetails.getOwnerName())) return false; 74 75 return true; 76 } 77 78 public int hashCode() { 79 int result; 80 result = getCreated().hashCode(); 81 result = 29 * result + getOwnerName().hashCode(); 82 return result; 83 } 84 85 public int compareTo(Object o) { 86 if (o instanceof BillingDetails) 88 return getCreated().compareTo( ((BillingDetails)o).getCreated() ); 89 return 0; 90 } 91 92 94 101 public abstract boolean isValid(); 102 103 } 104 | Popular Tags |