initial add of EbeanORM server based on v2.8.1

This commit is contained in:
rbygrave committed 2012-09-14 00:40:39 +12:00
1 parent 2b74d0f9d9
commit 96ce4c0ddf
1188 files changed
+135034

No files matched your search

@@ -0,0 +1,59 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.Embeddable;
import java.util.Date;
@Embeddable
public class AuditInfo
{
private Date lastUpdated;
private Date created;
private String updatedBy;
private String createdBy;
public AuditInfo()
{
created = new Date();
createdBy = "dummy";
}
public Date getLastUpdated()
{
return lastUpdated;
}
public void setLastUpdated(Date lastUpdated)
{
this.lastUpdated = lastUpdated;
}
public Date getCreated()
{
return created;
}
public void setCreated(Date created)
{
this.created = created;
}
public String getUpdatedBy()
{
return updatedBy;
}
public void setUpdatedBy(String updatedBy)
{
this.updatedBy = updatedBy;
}
public String getCreatedBy()
{
return createdBy;
}
public void setCreatedBy(String createdBy)
{
this.createdBy = createdBy;
}
}
@@ -0,0 +1,118 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.*;
@Entity
public class Item
{
@Id
private ItemKey key;
private String description;
private String units;
private int type;
private int region;
@Embedded
@AttributeOverrides({
@AttributeOverride(name = "lastUpdated", column = @Column(name = "DATE_MODIFIED")),
@AttributeOverride(name = "created", column = @Column(name = "DATE_CREATED")),
@AttributeOverride(name = "updatedBy", column = @Column(name = "MODIFIED_BY")),
@AttributeOverride(name = "createdBy", column = @Column(name = "CREATED_BY"))
})
private AuditInfo auditInfo = new AuditInfo();
@Version
private Long version;
@ManyToOne
@JoinColumns({
@JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false),
@JoinColumn(name = "type", referencedColumnName = "type", insertable = false, updatable = false)
})
private Type eType;
@ManyToOne
@JoinColumns({
@JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false),
@JoinColumn(name = "region", referencedColumnName = "type", insertable = false, updatable = false)
})
private Region eRegion;
public ItemKey getKey() {
return key;
}
public void setKey(ItemKey key) {
this.key = key;
}
public String getUnits()
{
return units;
}
public void setUnits(String units)
{
this.units = units;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int getRegion() {
return region;
}
public void setRegion(int region) {
this.region = region;
}
public Long getVersion() {
return version;
}
public Type getEType() {
return eType;
}
public Region getERegion() {
return eRegion;
}
public void setVersion(Long version)
{
this.version = version;
}
public void setEType(Type eType)
{
this.eType = eType;
}
public void setERegion(Region eRegion)
{
this.eRegion = eRegion;
}
public AuditInfo getAuditInfo()
{
return auditInfo;
}
}
@@ -0,0 +1,63 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.Embeddable;
import javax.persistence.Column;
@Embeddable
public class ItemKey
{
private int customer;
@Column(name = "itemNumber")
private String itemNumber;
public int getCustomer() {
return customer;
}
public void setCustomer(int customer) {
this.customer = customer;
}
public String getItemNumber() {
return itemNumber;
}
public void setItemNumber(String itemNumber) {
this.itemNumber = itemNumber;
}
@Override
public boolean equals(Object o)
{
if (this == o)
{
return true;
}
if (!(o instanceof ItemKey))
{
return false;
}
ItemKey itemKey = (ItemKey) o;
if (customer != itemKey.customer)
{
return false;
}
if (!itemNumber.equals(itemKey.itemNumber))
{
return false;
}
return true;
}
@Override
public int hashCode()
{
int result = customer;
result = 31 * result + itemNumber.hashCode();
return result;
}
}
@@ -0,0 +1,33 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.*;
@Entity
public class Parcel
{
@Id
@Column(name="parcelId")
private Long parcelId;
private String description;
public Long getParcelId()
{
return parcelId;
}
public void setParcelId(Long parcelId)
{
this.parcelId = parcelId;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
}
@@ -0,0 +1,52 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
@Entity
public class ParcelLocation
{
@Id
@Column(name="parcelLocId")
private Long parcelLocId;
private String location;
@OneToOne
@JoinColumn(name="parcelId", referencedColumnName = "parcelId")
private Parcel parcel;
public Long getParcelLocId()
{
return parcelLocId;
}
public void setParcelLocId(Long parcelLocId)
{
this.parcelLocId = parcelLocId;
}
public String getLocation()
{
return location;
}
public void setLocation(String location)
{
this.location = location;
}
public Parcel getParcel()
{
return parcel;
}
public void setParcel(Parcel parcel)
{
this.parcel = parcel;
}
}
@@ -0,0 +1,51 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.*;
import java.util.List;
@Entity
public class Region
{
@Id
private RegionKey key;
private String description;
@Version
private Long version;
@OneToMany
@JoinColumns({
@JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false),
@JoinColumn(name = "region", referencedColumnName = "type", insertable = false, updatable = false)
})
private List<Item> items;
public RegionKey getKey() {
return key;
}
public void setKey(RegionKey key) {
this.key = key;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public List<Item> getItems() {
return items;
}
}
@@ -0,0 +1,44 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.Embeddable;
@Embeddable
public class RegionKey
{
private int customer;
private int type;
public int getCustomer() {
return customer;
}
public void setCustomer(int customer) {
this.customer = customer;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int hashCode() {
int hc = 31 * 7 + customer;
hc = 31 * hc + type;
return hc;
}
public boolean equals(Object o){
if (this == o){
return true;
}
if (o instanceof RegionKey){
RegionKey k = (RegionKey)o;
return k.customer == customer && k.type == type;
}
return false;
}
}
@@ -0,0 +1,41 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Version;
@Entity
public class SubType
{
@EmbeddedId
private SubTypeKey key;
private String description;
@Version
private Long version;
public SubTypeKey getKey() {
return key;
}
public void setKey(SubTypeKey key) {
this.key = key;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
}
@@ -0,0 +1,34 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.Embeddable;
@Embeddable
public class SubTypeKey
{
private int subTypeId;
public int getSubTypeId()
{
return subTypeId;
}
public void setSubTypeId(int subTypeId)
{
this.subTypeId = subTypeId;
}
public int hashCode() {
return 31 * 7 + subTypeId;
}
public boolean equals(Object o){
if (this == o){
return true;
}
if (!(o instanceof SubTypeKey)) {
return false;
}
return subTypeId == ((SubTypeKey)o).subTypeId;
}
}
@@ -0,0 +1,62 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.*;
import java.util.List;
@Entity
public class Type
{
@Id
private TypeKey key;
private String description;
@Version
private Long version;
@OneToMany
@JoinColumns({
@JoinColumn(name = "customer", referencedColumnName = "customer", insertable = false, updatable = false),
@JoinColumn(name = "type", referencedColumnName = "type", insertable = false, updatable = false)
})
private List<Item> items;
@ManyToOne
private SubType subType;
public TypeKey getKey() {
return key;
}
public void setKey(TypeKey key) {
this.key = key;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public List<Item> getItems() {
return items;
}
public SubType getSubType() {
return subType;
}
public void setSubType(SubType subType) {
this.subType = subType;
}
}
@@ -0,0 +1,44 @@
package com.avaje.tests.compositekeys.db;
import javax.persistence.Embeddable;
@Embeddable
public class TypeKey
{
private int customer;
private int type;
public int getCustomer() {
return customer;
}
public void setCustomer(int customer) {
this.customer = customer;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public int hashCode() {
int hc = 31+customer;
hc = hc * 31 + type;
return hc;
}
public boolean equals(Object o){
if (this == o){
return true;
}
if (o instanceof TypeKey){
TypeKey k = (TypeKey)o;
return k.customer == customer && k.type == type;
}
return false;
}
}