package nl.ordina.odag.ejb3.domain; import static javax.persistence.GenerationType.TABLE; import java.io.Serializable; import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.Column; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.TableGenerator; import javax.persistence.Version; @Entity public class Course implements Serializable{ /** * */ private static final long serialVersionUID = 1L; @TableGenerator( name="courseGen", table="ID_GEN", pkColumnName="GEN_KEY", valueColumnName="GEN_VALUE", pkColumnValue="COURSE_ID") @Id @GeneratedValue(strategy=TABLE, generator="courseGen") private Long id; @Column(length=6) private String code; @Column(length=100) private String name; @Column(name="duration") private short duration; @Column(length=255) private String description; @Embedded @AttributeOverrides({ @AttributeOverride(name="currencyCode",column=@Column(name="CURR_CODE")), @AttributeOverride(name="amount",column=@Column(name="PRICE")) }) private MonetaryAmount price; @Version private int version; public Long getId() { return id; } protected void setId(Long id) { // this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } @Override public int hashCode() { final int PRIME = 31; int result = 1; result = PRIME * result + ((id == null) ? 0 : id.hashCode()); result = PRIME * result + ((name == null) ? 0 : name.hashCode()); result = PRIME * result + ((code == null) ? 0 : code.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; final Course other = (Course) obj; if (id == null) { if (other.id != null) return false; } else if (!id.equals(other.id)) return false; if (name == null) { if (other.name != null) return false; } else if (!name.equals(other.name)) return false; if (code == null) { if (other.code != null) return false; } else if (!code.equals(other.code)) return false; return true; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public short getDuration() { return duration; } public void setDuration(short duration) { this.duration = duration; } public MonetaryAmount getPrice() { return price; } public void setPrice(MonetaryAmount price) { this.price = price; } }