mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#919 - io.ebean package initial
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package org.tests.model;
|
||||
|
||||
import io.ebean.Model;
|
||||
import io.ebean.annotation.WhenCreated;
|
||||
import io.ebean.annotation.WhenModified;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@MappedSuperclass
|
||||
public class BaseModel extends Model {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
@WhenCreated
|
||||
Timestamp whenCreated;
|
||||
|
||||
@WhenModified
|
||||
Timestamp whenModified;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Timestamp getWhenCreated() {
|
||||
return whenCreated;
|
||||
}
|
||||
|
||||
public void setWhenCreated(Timestamp whenCreated) {
|
||||
this.whenCreated = whenCreated;
|
||||
}
|
||||
|
||||
public Timestamp getWhenModified() {
|
||||
return whenModified;
|
||||
}
|
||||
|
||||
public void setWhenModified(Timestamp whenModified) {
|
||||
this.whenModified = whenModified;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package org.tests.model;
|
||||
|
||||
import io.ebean.annotation.CreatedTimestamp;
|
||||
import io.ebean.annotation.UpdatedTimestamp;
|
||||
import io.ebean.annotation.WhenCreated;
|
||||
import io.ebean.annotation.WhenModified;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
@Entity
|
||||
public class EGenProps {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
@WhenCreated
|
||||
Timestamp whenCreated;
|
||||
|
||||
@WhenModified
|
||||
Timestamp whenModified;
|
||||
|
||||
@CreatedTimestamp
|
||||
Timestamp tsCreated;
|
||||
|
||||
@UpdatedTimestamp
|
||||
Timestamp tsUpdated;
|
||||
|
||||
@CreatedTimestamp
|
||||
LocalDateTime ldtCreated;
|
||||
|
||||
@UpdatedTimestamp
|
||||
LocalDateTime ldtUpdated;
|
||||
|
||||
@CreatedTimestamp
|
||||
OffsetDateTime odtCreated;
|
||||
|
||||
@UpdatedTimestamp
|
||||
OffsetDateTime odtUpdated;
|
||||
|
||||
@CreatedTimestamp
|
||||
ZonedDateTime zdtCreated;
|
||||
|
||||
@UpdatedTimestamp
|
||||
ZonedDateTime zdtUpdated;
|
||||
|
||||
@CreatedTimestamp
|
||||
Instant instantCreated;
|
||||
|
||||
@UpdatedTimestamp
|
||||
Instant instantUpdated;
|
||||
|
||||
@CreatedTimestamp
|
||||
long longCreated;
|
||||
|
||||
@UpdatedTimestamp
|
||||
long longUpdated;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Timestamp getWhenCreated() {
|
||||
return whenCreated;
|
||||
}
|
||||
|
||||
public void setWhenCreated(Timestamp whenCreated) {
|
||||
this.whenCreated = whenCreated;
|
||||
}
|
||||
|
||||
public Timestamp getWhenModified() {
|
||||
return whenModified;
|
||||
}
|
||||
|
||||
public void setWhenModified(Timestamp whenModified) {
|
||||
this.whenModified = whenModified;
|
||||
}
|
||||
|
||||
public Timestamp getTsCreated() {
|
||||
return tsCreated;
|
||||
}
|
||||
|
||||
public void setTsCreated(Timestamp tsCreated) {
|
||||
this.tsCreated = tsCreated;
|
||||
}
|
||||
|
||||
public Timestamp getTsUpdated() {
|
||||
return tsUpdated;
|
||||
}
|
||||
|
||||
public void setTsUpdated(Timestamp tsUpdated) {
|
||||
this.tsUpdated = tsUpdated;
|
||||
}
|
||||
|
||||
public LocalDateTime getLdtCreated() {
|
||||
return ldtCreated;
|
||||
}
|
||||
|
||||
public void setLdtCreated(LocalDateTime ldtCreated) {
|
||||
this.ldtCreated = ldtCreated;
|
||||
}
|
||||
|
||||
public LocalDateTime getLdtUpdated() {
|
||||
return ldtUpdated;
|
||||
}
|
||||
|
||||
public void setLdtUpdated(LocalDateTime ldtUpdated) {
|
||||
this.ldtUpdated = ldtUpdated;
|
||||
}
|
||||
|
||||
public OffsetDateTime getOdtCreated() {
|
||||
return odtCreated;
|
||||
}
|
||||
|
||||
public void setOdtCreated(OffsetDateTime odtCreated) {
|
||||
this.odtCreated = odtCreated;
|
||||
}
|
||||
|
||||
public OffsetDateTime getOdtUpdated() {
|
||||
return odtUpdated;
|
||||
}
|
||||
|
||||
public void setOdtUpdated(OffsetDateTime odtUpdated) {
|
||||
this.odtUpdated = odtUpdated;
|
||||
}
|
||||
|
||||
public ZonedDateTime getZdtCreated() {
|
||||
return zdtCreated;
|
||||
}
|
||||
|
||||
public void setZdtCreated(ZonedDateTime zdtCreated) {
|
||||
this.zdtCreated = zdtCreated;
|
||||
}
|
||||
|
||||
public ZonedDateTime getZdtUpdated() {
|
||||
return zdtUpdated;
|
||||
}
|
||||
|
||||
public void setZdtUpdated(ZonedDateTime zdtUpdated) {
|
||||
this.zdtUpdated = zdtUpdated;
|
||||
}
|
||||
|
||||
public long getLongCreated() {
|
||||
return longCreated;
|
||||
}
|
||||
|
||||
public void setLongCreated(long longCreated) {
|
||||
this.longCreated = longCreated;
|
||||
}
|
||||
|
||||
public long getLongUpdated() {
|
||||
return longUpdated;
|
||||
}
|
||||
|
||||
public void setLongUpdated(long longUpdated) {
|
||||
this.longUpdated = longUpdated;
|
||||
}
|
||||
|
||||
public Instant getInstantCreated() {
|
||||
return instantCreated;
|
||||
}
|
||||
|
||||
public void setInstantCreated(Instant instantCreated) {
|
||||
this.instantCreated = instantCreated;
|
||||
}
|
||||
|
||||
public Instant getInstantUpdated() {
|
||||
return instantUpdated;
|
||||
}
|
||||
|
||||
public void setInstantUpdated(Instant instantUpdated) {
|
||||
this.instantUpdated = instantUpdated;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.tests.model;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class EWhoProps extends EWhoPropsSuper {
|
||||
|
||||
String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package org.tests.model;
|
||||
|
||||
import io.ebean.annotation.WhenCreated;
|
||||
import io.ebean.annotation.WhenModified;
|
||||
import io.ebean.annotation.WhoCreated;
|
||||
import io.ebean.annotation.WhoModified;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@MappedSuperclass
|
||||
public class EWhoPropsSuper {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
@WhenCreated
|
||||
Timestamp whenCreated;
|
||||
|
||||
@WhenModified
|
||||
Timestamp whenModified;
|
||||
|
||||
@WhoCreated
|
||||
String whoCreated;
|
||||
|
||||
@WhoModified
|
||||
String whoModified;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Timestamp getWhenCreated() {
|
||||
return whenCreated;
|
||||
}
|
||||
|
||||
public void setWhenCreated(Timestamp whenCreated) {
|
||||
this.whenCreated = whenCreated;
|
||||
}
|
||||
|
||||
public Timestamp getWhenModified() {
|
||||
return whenModified;
|
||||
}
|
||||
|
||||
public void setWhenModified(Timestamp whenModified) {
|
||||
this.whenModified = whenModified;
|
||||
}
|
||||
|
||||
public String getWhoCreated() {
|
||||
return whoCreated;
|
||||
}
|
||||
|
||||
public void setWhoCreated(String whoCreated) {
|
||||
this.whoCreated = whoCreated;
|
||||
}
|
||||
|
||||
public String getWhoModified() {
|
||||
return whoModified;
|
||||
}
|
||||
|
||||
public void setWhoModified(String whoModified) {
|
||||
this.whoModified = whoModified;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package org.tests.model.array;
|
||||
|
||||
|
||||
import io.ebean.annotation.DbArray;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
public class EArrayBean {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@DbArray(length = 300)
|
||||
List<String> phoneNumbers = new ArrayList<>();
|
||||
|
||||
@DbArray
|
||||
List<UUID> uids = new ArrayList<>();
|
||||
|
||||
@DbArray
|
||||
List<Long> otherIds = new ArrayList<>();
|
||||
|
||||
@DbArray
|
||||
List<Double> doubs;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<String> getPhoneNumbers() {
|
||||
return phoneNumbers;
|
||||
}
|
||||
|
||||
public void setPhoneNumbers(List<String> phoneNumbers) {
|
||||
this.phoneNumbers = phoneNumbers;
|
||||
}
|
||||
|
||||
public List<UUID> getUids() {
|
||||
return uids;
|
||||
}
|
||||
|
||||
public void setUids(List<UUID> uids) {
|
||||
this.uids = uids;
|
||||
}
|
||||
|
||||
public List<Long> getOtherIds() {
|
||||
return otherIds;
|
||||
}
|
||||
|
||||
public void setOtherIds(List<Long> otherIds) {
|
||||
this.otherIds = otherIds;
|
||||
}
|
||||
|
||||
public List<Double> getDoubs() {
|
||||
return doubs;
|
||||
}
|
||||
|
||||
public void setDoubs(List<Double> doubs) {
|
||||
this.doubs = doubs;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package org.tests.model.array;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Query;
|
||||
import org.avaje.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TestDbArray_basic extends BaseTestCase {
|
||||
|
||||
private EArrayBean bean = new EArrayBean();
|
||||
|
||||
private EArrayBean found;
|
||||
|
||||
@Test
|
||||
public void insert() {
|
||||
|
||||
bean.setName("some stuff");
|
||||
|
||||
List<String> phNumbers = bean.getPhoneNumbers();
|
||||
phNumbers.add("4321");
|
||||
phNumbers.add("9823");
|
||||
|
||||
|
||||
List<Double> doubles = new ArrayList<>();
|
||||
doubles.add(1.3);
|
||||
doubles.add(2.4);
|
||||
|
||||
bean.getUids().add(UUID.randomUUID());
|
||||
bean.getUids().add(UUID.randomUUID());
|
||||
bean.getOtherIds().add(95L);
|
||||
bean.getOtherIds().add(96L);
|
||||
bean.getOtherIds().add(97L);
|
||||
bean.setDoubs(doubles);
|
||||
|
||||
Ebean.save(bean);
|
||||
|
||||
found = Ebean.find(EArrayBean.class, bean.getId());
|
||||
|
||||
assertThat(found.getPhoneNumbers()).containsExactly("4321", "9823");
|
||||
|
||||
if (isPostgres()) {
|
||||
Query<EArrayBean> query = Ebean.find(EArrayBean.class)
|
||||
.where()
|
||||
.arrayContains("otherIds", 96L, 97L)
|
||||
.arrayContains("uids", bean.getUids().get(0))
|
||||
.arrayContains("phoneNumbers", "9823")
|
||||
.arrayIsNotEmpty("phoneNumbers")
|
||||
.query();
|
||||
|
||||
List<EArrayBean> list = query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains(" t0.other_ids @> array[?,?]::bigint[] ");
|
||||
assertThat(query.getGeneratedSql()).contains(" t0.uids @> array[?] ");
|
||||
assertThat(query.getGeneratedSql()).contains(" t0.phone_numbers @> array[?] ");
|
||||
assertThat(query.getGeneratedSql()).contains(" coalesce(cardinality(t0.phone_numbers),0) <> 0");
|
||||
assertThat(list).hasSize(1);
|
||||
|
||||
query = Ebean.find(EArrayBean.class)
|
||||
.where()
|
||||
.arrayIsEmpty("otherIds")
|
||||
.arrayNotContains("uids", bean.getUids().get(0))
|
||||
.query();
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains(" coalesce(cardinality(t0.other_ids),0) = 0");
|
||||
assertThat(query.getGeneratedSql()).contains(" not (t0.uids @> array[?])");
|
||||
}
|
||||
|
||||
json_parse_format();
|
||||
update_when_notDirty();
|
||||
update_when_dirty();
|
||||
}
|
||||
|
||||
//@Test//(dependsOnMethods = "insert")
|
||||
public void json_parse_format() {
|
||||
|
||||
String asJson = Ebean.json().toJson(found);
|
||||
assertThat(asJson).contains("\"phoneNumbers\":[\"4321\",\"9823\"]");
|
||||
assertThat(asJson).contains("\"id\":");
|
||||
|
||||
EArrayBean fromJson = Ebean.json().toBean(EArrayBean.class, asJson);
|
||||
assertEquals(found.getId(), fromJson.getId());
|
||||
assertEquals(found.getId(), fromJson.getId());
|
||||
assertEquals(found.getName(), fromJson.getName());
|
||||
assertThat(fromJson.getPhoneNumbers()).containsExactly("4321", "9823");
|
||||
}
|
||||
|
||||
//@Test//(dependsOnMethods = "insert")
|
||||
public void update_when_notDirty() {
|
||||
|
||||
found.setName("jack");
|
||||
LoggedSqlCollector.start();
|
||||
Ebean.save(found);
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
|
||||
// we don't update the phone numbers (as they are not dirty)
|
||||
assertThat(sql.get(0)).contains("update earray_bean set name=?, version=? where");
|
||||
}
|
||||
|
||||
//@Test//(dependsOnMethods = "update_when_notDirty")
|
||||
public void update_when_dirty() {
|
||||
|
||||
found.getPhoneNumbers().add("9987");
|
||||
found.getUids().add(UUID.randomUUID());
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
Ebean.save(found);
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
|
||||
assertThat(sql.get(0)).contains("update earray_bean set phone_numbers=?, uids=?, version=? where");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertNulls() {
|
||||
|
||||
EArrayBean bean = new EArrayBean();
|
||||
bean.setName("some nulls");
|
||||
bean.setPhoneNumbers(null);
|
||||
bean.setOtherIds(null);
|
||||
bean.setUids(null);
|
||||
|
||||
Ebean.save(bean);
|
||||
Ebean.delete(bean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void insertAll_when_hasNulls() {
|
||||
|
||||
EArrayBean bean = new EArrayBean();
|
||||
bean.setName("some nulls");
|
||||
bean.setPhoneNumbers(null);
|
||||
bean.setOtherIds(null);
|
||||
bean.setUids(null);
|
||||
|
||||
List<EArrayBean> all = new ArrayList<>();
|
||||
all.add(bean);
|
||||
|
||||
Ebean.saveAll(all);
|
||||
Ebean.deleteAll(all);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import org.tests.model.basic.metaannotation.SizeMedium;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Address entity bean.
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "o_address")
|
||||
public class Address {
|
||||
|
||||
@Id
|
||||
Short id;
|
||||
|
||||
@Size(max = 100)
|
||||
@Column(name = "line_1")
|
||||
String line1;
|
||||
|
||||
@SizeMedium
|
||||
@Column(name = "line_2")
|
||||
String line2;
|
||||
|
||||
@SizeMedium
|
||||
String city;
|
||||
|
||||
Timestamp cretime;
|
||||
|
||||
@Version
|
||||
Timestamp updtime;
|
||||
|
||||
@ManyToOne
|
||||
Country country;
|
||||
|
||||
|
||||
public String toString() {
|
||||
return id + " " + line1 + " " + line2 + " " + city + " " + country;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return id.
|
||||
*/
|
||||
public Short getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id.
|
||||
*/
|
||||
public void setId(Short id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return line 1.
|
||||
*/
|
||||
public String getLine1() {
|
||||
return line1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line 1.
|
||||
*/
|
||||
public void setLine1(String line1) {
|
||||
this.line1 = line1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return line 2.
|
||||
*/
|
||||
public String getLine2() {
|
||||
return line2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set line 2.
|
||||
*/
|
||||
public void setLine2(String line2) {
|
||||
this.line2 = line2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return city.
|
||||
*/
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set city.
|
||||
*/
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cretime.
|
||||
*/
|
||||
public Timestamp getCretime() {
|
||||
return cretime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cretime.
|
||||
*/
|
||||
public void setCretime(Timestamp cretime) {
|
||||
this.cretime = cretime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return updtime.
|
||||
*/
|
||||
public Timestamp getUpdtime() {
|
||||
return updtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set updtime.
|
||||
*/
|
||||
public void setUpdtime(Timestamp updtime) {
|
||||
this.updtime = updtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return country.
|
||||
*/
|
||||
public Country getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set country.
|
||||
*/
|
||||
public void setCountry(Country country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.InheritanceType;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
@DiscriminatorColumn(name = "species")
|
||||
public abstract class Animal {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
@Column(name = "species", insertable = false, updatable = false, nullable = false)
|
||||
String species;
|
||||
|
||||
@ManyToOne
|
||||
AnimalShelter shelter;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getSpecies() {
|
||||
return species;
|
||||
}
|
||||
|
||||
public void setSpecies(String species) {
|
||||
this.species = species;
|
||||
}
|
||||
|
||||
public AnimalShelter getShelter() {
|
||||
return shelter;
|
||||
}
|
||||
|
||||
public void setShelter(AnimalShelter shelter) {
|
||||
this.shelter = shelter;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.PrivateOwned;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Version;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class AnimalShelter {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToMany(cascade = CascadeType.PERSIST, mappedBy = "shelter")
|
||||
@PrivateOwned
|
||||
List<Animal> animals;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Animal> getAnimals() {
|
||||
return animals;
|
||||
}
|
||||
|
||||
public void setAnimals(List<Animal> animals) {
|
||||
this.animals = animals;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.CacheBeanTuning;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Cache
|
||||
@CacheBeanTuning(maxSecsToLive = 45)
|
||||
@Entity
|
||||
public class Article extends BasicDomain {
|
||||
|
||||
String name;
|
||||
|
||||
String author;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
List<Section> sections;
|
||||
|
||||
public Article() {
|
||||
}
|
||||
|
||||
public Article(String name, String author) {
|
||||
this.name = name;
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public List<Section> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(List<Section> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
public void addSection(Section s) {
|
||||
if (sections == null) {
|
||||
sections = new ArrayList<>();
|
||||
}
|
||||
sections.add(s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.DiscriminatorType;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
@Inheritance()
|
||||
@DiscriminatorColumn(name = "option_type", discriminatorType = DiscriminatorType.INTEGER)
|
||||
@DiscriminatorValue("0")
|
||||
public class Attribute extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ManyToOne
|
||||
private AttributeHolder attributeHolder;
|
||||
|
||||
public AttributeHolder getAttributeHolder() {
|
||||
return attributeHolder;
|
||||
}
|
||||
|
||||
public void setAttributeHolder(AttributeHolder attributeHolder) {
|
||||
this.attributeHolder = attributeHolder;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
public class AttributeHolder extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@OneToMany(mappedBy = "attributeHolder", cascade = {CascadeType.PERSIST})
|
||||
private Set<Attribute> attributes;// = new HashSet<Attribute>();
|
||||
|
||||
public Set<Attribute> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
public void setAttributes(Set<Attribute> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
public void add(Attribute attribute) {
|
||||
getAttributes().add(attribute);
|
||||
attribute.setAttributeHolder(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
/**
|
||||
* A user may have multiple bookmarks
|
||||
*
|
||||
* @author Chris
|
||||
*/
|
||||
@Entity
|
||||
public class BBookmark {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
|
||||
@Column
|
||||
private String bookmarkReference;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.PERSIST)
|
||||
@Column
|
||||
private BBookmarkUser user;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(final Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the bookmarkReference
|
||||
*/
|
||||
public String getBookmarkReference() {
|
||||
return this.bookmarkReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bookmarkReference the bookmarkReference to set
|
||||
*/
|
||||
public void setBookmarkReference(final String bookmarkReference) {
|
||||
this.bookmarkReference = bookmarkReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user
|
||||
*/
|
||||
public BBookmarkUser getUser() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user the user to set
|
||||
*/
|
||||
public void setUser(final BBookmarkUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* represents a user entity. A user contains a username and password.
|
||||
*
|
||||
* @author Chris
|
||||
*/
|
||||
@Entity
|
||||
public class BBookmarkUser {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Integer id;
|
||||
|
||||
@Column
|
||||
private String name;
|
||||
|
||||
@Column
|
||||
private String password;
|
||||
|
||||
@Column
|
||||
private String emailAddress;
|
||||
|
||||
@Column
|
||||
private String country;
|
||||
|
||||
// @Version
|
||||
// private Timestamp lastUpdate;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(final Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the password
|
||||
*/
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param password the password to set
|
||||
*/
|
||||
public void setPassword(final String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the emailAddress
|
||||
*/
|
||||
public String getEmailAddress() {
|
||||
return this.emailAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param emailAddress the emailAddress to set
|
||||
*/
|
||||
public void setEmailAddress(final String emailAddress) {
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the country
|
||||
*/
|
||||
public String getCountry() {
|
||||
return this.country;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param country the country to set
|
||||
*/
|
||||
public void setCountry(final String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
// public Timestamp getLastUpdate() {
|
||||
// return lastUpdate;
|
||||
// }
|
||||
//
|
||||
// public void setLastUpdate(Timestamp lastUpdate) {
|
||||
// this.lastUpdate = lastUpdate;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
public class BWithQIdent {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@Column(name = "`Name`", unique = true)
|
||||
String name;
|
||||
|
||||
@Version
|
||||
Timestamp lastUpdated;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Timestamp getLastUpdated() {
|
||||
return lastUpdated;
|
||||
}
|
||||
|
||||
public void setLastUpdated(Timestamp lastUpdated) {
|
||||
this.lastUpdated = lastUpdated;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.WhenCreated;
|
||||
import io.ebean.annotation.WhenModified;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.Version;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@MappedSuperclass
|
||||
public class BasicDomain implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5569496199004449769L;
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@WhenCreated
|
||||
Timestamp cretime;
|
||||
|
||||
@WhenModified
|
||||
Timestamp updtime;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Timestamp getUpdtime() {
|
||||
return updtime;
|
||||
}
|
||||
|
||||
public void setUpdtime(Timestamp updtime) {
|
||||
this.updtime = updtime;
|
||||
}
|
||||
|
||||
public Timestamp getCretime() {
|
||||
return cretime;
|
||||
}
|
||||
|
||||
public void setCretime(Timestamp cretime) {
|
||||
this.cretime = cretime;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@Entity
|
||||
public class BeanWithTimeZone {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
TimeZone timezone;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public TimeZone getTimezone() {
|
||||
return timezone;
|
||||
}
|
||||
|
||||
public void setTimezone(TimeZone timezone) {
|
||||
this.timezone = timezone;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
@DiscriminatorValue("BDG")
|
||||
public class BigDog extends Dog {
|
||||
|
||||
String dogSize;
|
||||
|
||||
public String getDogSize() {
|
||||
return dogSize;
|
||||
}
|
||||
|
||||
public void setDogSize(String dogSize) {
|
||||
this.dogSize = dogSize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class CKeyAssoc {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String assocOne;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAssocOne() {
|
||||
return assocOne;
|
||||
}
|
||||
|
||||
public void setAssocOne(String assocOne) {
|
||||
this.assocOne = assocOne;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class CKeyDetail {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String something;
|
||||
|
||||
@ManyToOne
|
||||
// @JoinColumns({
|
||||
// @JoinColumn(name="parent_one_key", referencedColumnName="one_key"),
|
||||
// @JoinColumn(name="parent_two_key", referencedColumnName="two_key")
|
||||
// })
|
||||
CKeyParent parent;
|
||||
|
||||
public CKeyDetail() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyDetail(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public CKeyParent getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(CKeyParent parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.EmbeddedId;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Version;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class CKeyParent {
|
||||
|
||||
@EmbeddedId
|
||||
CKeyParentId id;
|
||||
|
||||
String name;
|
||||
|
||||
@Version
|
||||
int version;
|
||||
|
||||
@ManyToOne(cascade = CascadeType.PERSIST)
|
||||
CKeyAssoc assoc;
|
||||
|
||||
@OneToMany(cascade = CascadeType.PERSIST, mappedBy = "parent")
|
||||
List<CKeyDetail> details;
|
||||
|
||||
public CKeyParentId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(CKeyParentId id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(int version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public CKeyAssoc getAssoc() {
|
||||
return assoc;
|
||||
}
|
||||
|
||||
public void setAssoc(CKeyAssoc assoc) {
|
||||
this.assoc = assoc;
|
||||
}
|
||||
|
||||
public List<CKeyDetail> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(List<CKeyDetail> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public void add(CKeyDetail detail) {
|
||||
if (details == null) {
|
||||
details = new ArrayList<>();
|
||||
}
|
||||
details.add(detail);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
|
||||
@Embeddable
|
||||
public class CKeyParentId {
|
||||
|
||||
Integer oneKey;
|
||||
String twoKey;
|
||||
|
||||
public CKeyParentId() {
|
||||
|
||||
}
|
||||
|
||||
public CKeyParentId(Integer oneKey, String twoKey) {
|
||||
this.oneKey = oneKey;
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
public Integer getOneKey() {
|
||||
return oneKey;
|
||||
}
|
||||
|
||||
public void setOneKey(Integer oneKey) {
|
||||
this.oneKey = oneKey;
|
||||
}
|
||||
|
||||
public String getTwoKey() {
|
||||
return twoKey;
|
||||
}
|
||||
|
||||
public void setTwoKey(String twoKey) {
|
||||
this.twoKey = twoKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof CKeyParentId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CKeyParentId otherKey = (CKeyParentId) o;
|
||||
return otherKey.hashCode() == hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hc = getClass().getName().hashCode();
|
||||
hc = 31 * hc + oneKey;
|
||||
hc = 31 * hc + twoKey.hashCode();
|
||||
return hc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.DbEnumValue;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderBy;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Inheritance
|
||||
@DiscriminatorValue("C")
|
||||
public class Car extends Vehicle {
|
||||
|
||||
public enum Size {
|
||||
SMALL("S"),
|
||||
LARGE("L");
|
||||
|
||||
String value;
|
||||
|
||||
Size(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@DbEnumValue
|
||||
public String value() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@Column(name = "siz")
|
||||
private Size size;
|
||||
|
||||
private String driver;
|
||||
|
||||
@ManyToOne
|
||||
private TruckRef carRef;
|
||||
|
||||
@OneToMany(mappedBy = "car")
|
||||
@OrderBy("fuse.locationCode")
|
||||
private Set<CarAccessory> accessories = new HashSet<>();
|
||||
|
||||
private String notes;
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public void setDriver(String driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public String getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public TruckRef getCarRef() {
|
||||
return carRef;
|
||||
}
|
||||
|
||||
public void setCarRef(TruckRef carRef) {
|
||||
this.carRef = carRef;
|
||||
}
|
||||
|
||||
public Set<CarAccessory> getAccessories() {
|
||||
return accessories;
|
||||
}
|
||||
|
||||
public void setAccessories(Set<CarAccessory> accessories) {
|
||||
this.accessories = accessories;
|
||||
}
|
||||
|
||||
public Size getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Size size) {
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class CarAccessory extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
private CarFuse fuse;
|
||||
|
||||
@ManyToOne
|
||||
private Car car;
|
||||
|
||||
public CarAccessory(Car car, CarFuse fuse) {
|
||||
this.car = car;
|
||||
this.fuse = fuse;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Car getCar() {
|
||||
return car;
|
||||
}
|
||||
|
||||
public void setCar(Car car) {
|
||||
this.car = car;
|
||||
}
|
||||
|
||||
public CarFuse getFuse() {
|
||||
return fuse;
|
||||
}
|
||||
|
||||
public void setFuse(CarFuse fuse) {
|
||||
this.fuse = fuse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class CarFuse {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String locationCode;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLocationCode() {
|
||||
return locationCode;
|
||||
}
|
||||
|
||||
public void setLocationCode(String locationCode) {
|
||||
this.locationCode = locationCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
@DiscriminatorValue("CAT")
|
||||
public class Cat extends Animal {
|
||||
|
||||
String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.ChangeLog;
|
||||
import io.ebean.annotation.CreatedTimestamp;
|
||||
import io.ebean.annotation.DocEmbedded;
|
||||
import io.ebean.annotation.DocStore;
|
||||
import io.ebean.annotation.Index;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
@DocStore
|
||||
@Index(columnNames = {"last_name", "first_name"})
|
||||
@ChangeLog
|
||||
@Entity
|
||||
@Cache(naturalKey = "email")
|
||||
public class Contact {
|
||||
|
||||
@Id
|
||||
int id;
|
||||
|
||||
String firstName;
|
||||
String lastName;
|
||||
|
||||
String phone;
|
||||
String mobile;
|
||||
String email;
|
||||
|
||||
@DocEmbedded(doc = "id,name")
|
||||
@ManyToOne(optional = false)
|
||||
Customer customer;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
ContactGroup group;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
List<ContactNote> notes;
|
||||
|
||||
@CreatedTimestamp
|
||||
Timestamp cretime;
|
||||
|
||||
@Version
|
||||
Timestamp updtime;
|
||||
|
||||
|
||||
public Contact(String firstName, String lastName) {
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public Contact() {
|
||||
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Timestamp getUpdtime() {
|
||||
return updtime;
|
||||
}
|
||||
|
||||
public void setUpdtime(Timestamp updtime) {
|
||||
this.updtime = updtime;
|
||||
}
|
||||
|
||||
public Timestamp getCretime() {
|
||||
return cretime;
|
||||
}
|
||||
|
||||
public void setCretime(Timestamp cretime) {
|
||||
this.cretime = cretime;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public ContactGroup getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
public void setGroup(ContactGroup group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public List<ContactNote> getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(List<ContactNote> notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class ContactGroup extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = -5447111032760796085L;
|
||||
|
||||
String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
@Entity
|
||||
public class ContactNote extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 7949702621226333278L;
|
||||
|
||||
@ManyToOne
|
||||
Contact contact;
|
||||
|
||||
String title;
|
||||
|
||||
@Size(max = 2000)
|
||||
@Lob
|
||||
String note;
|
||||
|
||||
public ContactNote(String title, String note) {
|
||||
this.title = title;
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public Contact getContact() {
|
||||
return contact;
|
||||
}
|
||||
|
||||
public void setContact(Contact contact) {
|
||||
this.contact = contact;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.CacheBeanTuning;
|
||||
import io.ebean.annotation.ChangeLog;
|
||||
import io.ebean.annotation.ChangeLogInsertMode;
|
||||
import io.ebean.annotation.DocStore;
|
||||
import io.ebean.annotation.ReadAudit;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
/**
|
||||
* Country entity bean.
|
||||
*/
|
||||
@DocStore
|
||||
@ReadAudit
|
||||
@ChangeLog(inserts = ChangeLogInsertMode.INCLUDE)
|
||||
@Cache(readOnly = true, enableQueryCache = true)
|
||||
@CacheBeanTuning(maxSize = 500)
|
||||
@Entity
|
||||
@Table(name = "o_country")
|
||||
public class Country {
|
||||
|
||||
@Id
|
||||
@Size(max = 2)
|
||||
String code;
|
||||
|
||||
@Size(max = 60)
|
||||
String name;
|
||||
|
||||
public String toString() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return code.
|
||||
*/
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set code.
|
||||
*/
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.ChangeLog;
|
||||
import io.ebean.annotation.ChangeLogInsertMode;
|
||||
import io.ebean.annotation.DbComment;
|
||||
import io.ebean.annotation.DbEnumValue;
|
||||
import io.ebean.annotation.DocEmbedded;
|
||||
import io.ebean.annotation.DocStore;
|
||||
import io.ebean.annotation.JsonIgnore;
|
||||
import io.ebean.annotation.Where;
|
||||
import org.tests.model.basic.finder.CustomerFinder;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.NamedQueries;
|
||||
import javax.persistence.NamedQuery;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* Customer entity bean.
|
||||
*/
|
||||
@NamedQueries(
|
||||
value = {
|
||||
@NamedQuery(name = "name", query = "select(name) order by name"),
|
||||
@NamedQuery(name = "withStatus", query = "select(name,status) order by name")
|
||||
}
|
||||
)
|
||||
@NamedQuery(name = "withContacts", query = "fetch contacts (firstName, lastName) where id = :id")
|
||||
@Cache(enableQueryCache = true)
|
||||
@DocStore
|
||||
@ChangeLog(inserts = ChangeLogInsertMode.EXCLUDE, updatesThatInclude = {"name", "status"})
|
||||
@Entity
|
||||
@Table(name = "o_customer")
|
||||
@DbComment("Holds external customers")
|
||||
public class Customer extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final CustomerFinder find = new CustomerFinder();
|
||||
|
||||
/**
|
||||
* EnumValue is an Ebean specific mapping for enums.
|
||||
*/
|
||||
public enum Status {
|
||||
NEW("N"),
|
||||
ACTIVE("A"),
|
||||
INACTIVE("I");
|
||||
|
||||
String dbValue;
|
||||
|
||||
Status(String dbValue) {
|
||||
this.dbValue = dbValue;
|
||||
}
|
||||
|
||||
@DbEnumValue
|
||||
public String getValue() {
|
||||
return dbValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Transient
|
||||
Boolean selected;
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
//@Expose(deserialize = false, serialize = false)
|
||||
@Transient
|
||||
ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
@DbComment("status of the customer")
|
||||
Status status;
|
||||
|
||||
@NotNull
|
||||
@Size(max = 40)
|
||||
String name;
|
||||
|
||||
@DbComment("Short notes regarding the customer")
|
||||
@Size(max = 100)
|
||||
String smallnote;
|
||||
|
||||
@DbComment("Join date of the customer")
|
||||
@NotNull(groups = {ValidationGroupSomething.class})
|
||||
Date anniversary;
|
||||
|
||||
@DocEmbedded(doc = "*,country(*)")
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
Address billingAddress;
|
||||
|
||||
@DocEmbedded(doc = "*,country(*)")
|
||||
@ManyToOne(cascade = CascadeType.ALL)
|
||||
Address shippingAddress;
|
||||
|
||||
@OneToMany(mappedBy = "customer")
|
||||
@Where(clause = "${ta}.order_date is not null")
|
||||
List<Order> orders;
|
||||
|
||||
@OneToMany(mappedBy = "customer", cascade = CascadeType.ALL)
|
||||
List<Contact> contacts;
|
||||
|
||||
public String toString() {
|
||||
return id + " " + status + " " + name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return billing address.
|
||||
*/
|
||||
public Address getBillingAddress() {
|
||||
return billingAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set billing address.
|
||||
*/
|
||||
public void setBillingAddress(Address billingAddress) {
|
||||
this.billingAddress = billingAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return status.
|
||||
*/
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set status.
|
||||
*/
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return shipping address.
|
||||
*/
|
||||
public Address getShippingAddress() {
|
||||
return shippingAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set shipping address.
|
||||
*/
|
||||
public void setShippingAddress(Address shippingAddress) {
|
||||
this.shippingAddress = shippingAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return orders.
|
||||
*/
|
||||
public List<Order> getOrders() {
|
||||
return orders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set orders.
|
||||
*/
|
||||
public void setOrders(List<Order> orders) {
|
||||
this.orders = orders;
|
||||
}
|
||||
|
||||
public Boolean getSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
public void setSelected(Boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
public ReentrantLock getLock() {
|
||||
return lock;
|
||||
}
|
||||
|
||||
public String getSmallnote() {
|
||||
return smallnote;
|
||||
}
|
||||
|
||||
public void setSmallnote(String smallnote) {
|
||||
this.smallnote = smallnote;
|
||||
}
|
||||
|
||||
public Date getAnniversary() {
|
||||
return anniversary;
|
||||
}
|
||||
|
||||
public void setAnniversary(Date anniversary) {
|
||||
this.anniversary = anniversary;
|
||||
}
|
||||
|
||||
public List<Contact> getContacts() {
|
||||
return contacts;
|
||||
}
|
||||
|
||||
public void setContacts(List<Contact> contacts) {
|
||||
this.contacts = contacts;
|
||||
}
|
||||
|
||||
public void addContact(Contact contact) {
|
||||
if (contacts == null) {
|
||||
contacts = new ArrayList<>();
|
||||
}
|
||||
contacts.add(contact);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Sql;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
/**
|
||||
* An example of an Aggregate object.
|
||||
* <p>
|
||||
* Note the @Sql indicates to Ebean that this bean is not based on a table but
|
||||
* instead uses RawSql.
|
||||
* </p>
|
||||
*/
|
||||
@Entity
|
||||
@Sql
|
||||
public class CustomerAggregate {
|
||||
|
||||
@OneToOne
|
||||
Customer customer;
|
||||
|
||||
int totalContacts;
|
||||
|
||||
|
||||
public String toString() {
|
||||
return customer.getId() + " totalContacts:" + totalContacts;
|
||||
}
|
||||
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
|
||||
public void setCustomer(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
|
||||
public int getTotalContacts() {
|
||||
return totalContacts;
|
||||
}
|
||||
|
||||
|
||||
public void setTotalContacts(int totalContacts) {
|
||||
this.totalContacts = totalContacts;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import java.sql.Date;
|
||||
|
||||
@Entity
|
||||
@DiscriminatorValue("DOG")
|
||||
public class Dog extends Animal {
|
||||
|
||||
String registrationNumber;
|
||||
|
||||
Date dateOfBirth;
|
||||
|
||||
public String getRegistrationNumber() {
|
||||
return registrationNumber;
|
||||
}
|
||||
|
||||
public void setRegistrationNumber(String registrationNumber) {
|
||||
this.registrationNumber = registrationNumber;
|
||||
}
|
||||
|
||||
public Date getDateOfBirth() {
|
||||
return dateOfBirth;
|
||||
}
|
||||
|
||||
public void setDateOfBirth(Date dateOfBirth) {
|
||||
this.dateOfBirth = dateOfBirth;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.EnumValue;
|
||||
import io.ebean.annotation.Index;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "e_basic")
|
||||
public class EBasic {
|
||||
|
||||
public enum Status {
|
||||
@EnumValue("N")
|
||||
NEW,
|
||||
|
||||
@EnumValue("A")
|
||||
ACTIVE,
|
||||
|
||||
@EnumValue("I")
|
||||
INACTIVE,
|
||||
}
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Status status;
|
||||
|
||||
@Index
|
||||
String name;
|
||||
|
||||
String description;
|
||||
|
||||
Timestamp someDate;
|
||||
|
||||
public EBasic() {
|
||||
|
||||
}
|
||||
|
||||
public EBasic(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Timestamp getSomeDate() {
|
||||
return someDate;
|
||||
}
|
||||
|
||||
public void setSomeDate(Timestamp someDate) {
|
||||
this.someDate = someDate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.ChangeLog;
|
||||
import io.ebean.annotation.ReadAudit;
|
||||
import io.ebean.annotation.WhenCreated;
|
||||
import io.ebean.annotation.WhenModified;
|
||||
import io.ebean.annotation.WhoCreated;
|
||||
import io.ebean.annotation.WhoModified;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Cache(enableQueryCache = true)
|
||||
@ReadAudit
|
||||
@ChangeLog(updatesThatInclude = {"name", "shortDescription"})
|
||||
@Entity
|
||||
public class EBasicChangeLog {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@Size(max = 20)
|
||||
String name;
|
||||
|
||||
@Size(max = 50)
|
||||
String shortDescription;
|
||||
|
||||
@Size(max = 100)
|
||||
String longDescription;
|
||||
|
||||
@WhoCreated
|
||||
String whoCreated;
|
||||
|
||||
@WhoModified
|
||||
String whoModified;
|
||||
|
||||
@WhenCreated
|
||||
Timestamp whenCreated;
|
||||
|
||||
@WhenModified
|
||||
Timestamp whenModified;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getShortDescription() {
|
||||
return shortDescription;
|
||||
}
|
||||
|
||||
public void setShortDescription(String shortDescription) {
|
||||
this.shortDescription = shortDescription;
|
||||
}
|
||||
|
||||
public String getLongDescription() {
|
||||
return longDescription;
|
||||
}
|
||||
|
||||
public void setLongDescription(String longDescription) {
|
||||
this.longDescription = longDescription;
|
||||
}
|
||||
|
||||
public String getWhoCreated() {
|
||||
return whoCreated;
|
||||
}
|
||||
|
||||
public void setWhoCreated(String whoCreated) {
|
||||
this.whoCreated = whoCreated;
|
||||
}
|
||||
|
||||
public String getWhoModified() {
|
||||
return whoModified;
|
||||
}
|
||||
|
||||
public void setWhoModified(String whoModified) {
|
||||
this.whoModified = whoModified;
|
||||
}
|
||||
|
||||
public Timestamp getWhenCreated() {
|
||||
return whenCreated;
|
||||
}
|
||||
|
||||
public void setWhenCreated(Timestamp whenCreated) {
|
||||
this.whenCreated = whenCreated;
|
||||
}
|
||||
|
||||
public Timestamp getWhenModified() {
|
||||
return whenModified;
|
||||
}
|
||||
|
||||
public void setWhenModified(Timestamp whenModified) {
|
||||
this.whenModified = whenModified;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
public class EBasicClob {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String title;
|
||||
|
||||
@Lob
|
||||
private String description;
|
||||
|
||||
@Version
|
||||
private Timestamp lastUpdate;
|
||||
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Timestamp getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
public void setLastUpdate(Timestamp lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
public class EBasicClobFetchEager {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* Lob properties default to FetchType.LAZY and need to be explicitly included in a fetch
|
||||
* via query.select("*") or by defaulting them to FetchType.EAGER as this case.
|
||||
*/
|
||||
@Lob
|
||||
@Basic(fetch = FetchType.EAGER)
|
||||
private String description;
|
||||
|
||||
@Version
|
||||
private Timestamp lastUpdate;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Timestamp getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
public void setLastUpdate(Timestamp lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
|
||||
@Entity
|
||||
public class EBasicClobNoVer {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* Note that lobs default to FetchType.LAZY - see EBasicClobFetchEager.
|
||||
*/
|
||||
@Lob
|
||||
private String description;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Encrypted;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "e_basicenc")
|
||||
public class EBasicEncrypt {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
//@Lob
|
||||
@Encrypted(dbLength = 80)
|
||||
String description;
|
||||
|
||||
@Encrypted(dbLength = 20)
|
||||
Date dob;
|
||||
|
||||
//@Version
|
||||
Timestamp lastUpdate;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Date getDob() {
|
||||
return dob;
|
||||
}
|
||||
|
||||
public void setDob(Date dob) {
|
||||
this.dob = dob;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Timestamp getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
public void setLastUpdate(Timestamp lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Encrypted;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "e_basicenc_bin")
|
||||
public class EBasicEncryptBinary {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
String description;
|
||||
|
||||
@Encrypted
|
||||
@Lob
|
||||
byte[] data;
|
||||
|
||||
@Encrypted
|
||||
Timestamp someTime;
|
||||
|
||||
@Version
|
||||
Timestamp lastUpdate;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(byte[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Timestamp getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
public void setLastUpdate(Timestamp lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
}
|
||||
|
||||
public Timestamp getSomeTime() {
|
||||
return someTime;
|
||||
}
|
||||
|
||||
public void setSomeTime(Timestamp someTime) {
|
||||
this.someTime = someTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.EnumValue;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "e_basic_enum_id")
|
||||
public class EBasicEnumId {
|
||||
|
||||
public enum Status {
|
||||
@EnumValue("N")
|
||||
NEW,
|
||||
|
||||
@EnumValue("A")
|
||||
ACTIVE,
|
||||
|
||||
@EnumValue("I")
|
||||
INACTIVE,
|
||||
}
|
||||
|
||||
@Id
|
||||
Status status;
|
||||
|
||||
String name;
|
||||
|
||||
String description;
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.DbEnumType;
|
||||
import io.ebean.annotation.DbEnumValue;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "e_basic_eni")
|
||||
public class EBasicEnumInt {
|
||||
|
||||
public enum Status {
|
||||
NEW("1"),
|
||||
ACTIVE("2"),
|
||||
INACTIVE("3");
|
||||
|
||||
String value;
|
||||
|
||||
Status(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@DbEnumValue(storage = DbEnumType.INTEGER)
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Status status;
|
||||
|
||||
String name;
|
||||
|
||||
String description;
|
||||
|
||||
Timestamp someDate;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Timestamp getSomeDate() {
|
||||
return someDate;
|
||||
}
|
||||
|
||||
public void setSomeDate(Timestamp someDate) {
|
||||
this.someDate = someDate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "e_basic_ndc")
|
||||
public class EBasicNoDefaultConstructor {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
public EBasicNoDefaultConstructor() {
|
||||
}
|
||||
|
||||
public EBasicNoDefaultConstructor(Integer id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Cache(enableQueryCache = true)
|
||||
@Entity
|
||||
@Table(name = "e_basicver")
|
||||
public class EBasicVer {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
String description;
|
||||
|
||||
String other;
|
||||
|
||||
@Version
|
||||
Timestamp lastUpdate;
|
||||
|
||||
public EBasicVer(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getOther() {
|
||||
return other;
|
||||
}
|
||||
|
||||
public void setOther(String other) {
|
||||
this.other = other;
|
||||
}
|
||||
|
||||
public Timestamp getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
public void setLastUpdate(Timestamp lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.PostSoftDelete;
|
||||
import io.ebean.annotation.PreSoftDelete;
|
||||
import io.ebean.annotation.SoftDelete;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.PostLoad;
|
||||
import javax.persistence.PostPersist;
|
||||
import javax.persistence.PostRemove;
|
||||
import javax.persistence.PostUpdate;
|
||||
import javax.persistence.PrePersist;
|
||||
import javax.persistence.PreRemove;
|
||||
import javax.persistence.PreUpdate;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
@Table(name = "e_basic_withlife")
|
||||
public class EBasicWithLifecycle {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@SoftDelete
|
||||
boolean deleted;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
transient StringBuilder buffer = new StringBuilder();
|
||||
|
||||
@PrePersist
|
||||
public void prePersist1() {
|
||||
buffer.append("prePersist1");
|
||||
}
|
||||
|
||||
@PrePersist
|
||||
public void prePersist2() {
|
||||
buffer.append("prePersist2");
|
||||
}
|
||||
|
||||
@PostPersist
|
||||
public void postPersist1() {
|
||||
buffer.append("postPersist1");
|
||||
}
|
||||
|
||||
@PostPersist
|
||||
public void postPersist2() {
|
||||
buffer.append("postPersist2");
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
public void preUpdate1() {
|
||||
buffer.append("preUpdate1");
|
||||
}
|
||||
|
||||
@PreUpdate
|
||||
public void preUpdate2() {
|
||||
buffer.append("preUpdate2");
|
||||
}
|
||||
|
||||
@PostUpdate
|
||||
public void postUpdate1() {
|
||||
buffer.append("postUpdate1");
|
||||
}
|
||||
|
||||
@PostUpdate
|
||||
public void postUpdate2() {
|
||||
buffer.append("postUpdate2");
|
||||
}
|
||||
|
||||
@PreRemove
|
||||
public void preRemove1() {
|
||||
buffer.append("preRemove1");
|
||||
}
|
||||
|
||||
@PreRemove
|
||||
public void preRemove2() {
|
||||
buffer.append("preRemove2");
|
||||
}
|
||||
|
||||
@PostRemove
|
||||
public void postRemove1() {
|
||||
buffer.append("postRemove1");
|
||||
}
|
||||
|
||||
@PostRemove
|
||||
public void postRemove2() {
|
||||
buffer.append("postRemove2");
|
||||
}
|
||||
|
||||
@PostSoftDelete
|
||||
public void postSoftDelete() {
|
||||
buffer.append("postSoftDelete");
|
||||
}
|
||||
|
||||
@PreSoftDelete
|
||||
public void preSoftDelete() {
|
||||
buffer.append("preSoftDelete");
|
||||
}
|
||||
|
||||
@PostLoad
|
||||
public void postLoad1() {
|
||||
buffer.append("postLoad1");
|
||||
}
|
||||
|
||||
@PostLoad
|
||||
public void postLoad2() {
|
||||
buffer.append("postLoad2");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct1() {
|
||||
buffer.append("postConstruct1");
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct2() {
|
||||
buffer.append("postConstruct2");
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getBuffer() {
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
import javax.persistence.Version;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "e_basicverucon")
|
||||
@UniqueConstraint(columnNames = {"other", "other_one"})
|
||||
public class EBasicWithUniqueCon {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@Column(unique = true)
|
||||
String name;
|
||||
|
||||
String other;
|
||||
String otherOne;
|
||||
String description;
|
||||
|
||||
@Version
|
||||
Timestamp lastUpdate;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getOther() {
|
||||
return other;
|
||||
}
|
||||
|
||||
public void setOther(String other) {
|
||||
this.other = other;
|
||||
}
|
||||
|
||||
public String getOtherOne() {
|
||||
return otherOne;
|
||||
}
|
||||
|
||||
public void setOtherOne(String otherOne) {
|
||||
this.otherOne = otherOne;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Timestamp getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
public void setLastUpdate(Timestamp lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class ECustomId {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(generator = "shortUid")
|
||||
String id;
|
||||
|
||||
String name;
|
||||
|
||||
public ECustomId(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class ENullCollection {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToMany(cascade = CascadeType.PERSIST)
|
||||
List<ENullCollectionDetail> details;
|
||||
|
||||
public ENullCollection() {
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<ENullCollectionDetail> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(List<ENullCollectionDetail> details) {
|
||||
this.details = details;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class ENullCollectionDetail {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String something;
|
||||
|
||||
public ENullCollectionDetail() {
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class EOptOneA extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
String nameForA;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
EOptOneB b;
|
||||
|
||||
public String getNameForA() {
|
||||
return nameForA;
|
||||
}
|
||||
|
||||
public void setNameForA(String nameForA) {
|
||||
this.nameForA = nameForA;
|
||||
}
|
||||
|
||||
public EOptOneB getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void setB(EOptOneB b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class EOptOneB extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
String nameForB;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
EOptOneC c;
|
||||
|
||||
public String getNameForB() {
|
||||
return nameForB;
|
||||
}
|
||||
|
||||
public void setNameForB(String nameForA) {
|
||||
this.nameForB = nameForA;
|
||||
}
|
||||
|
||||
public EOptOneC getC() {
|
||||
return c;
|
||||
}
|
||||
|
||||
public void setC(EOptOneC c) {
|
||||
this.c = c;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@Entity
|
||||
public class EOptOneC extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
String nameForC;
|
||||
|
||||
public String getNameForC() {
|
||||
return nameForC;
|
||||
}
|
||||
|
||||
public void setNameForC(String nameForA) {
|
||||
this.nameForC = nameForA;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class ESimple {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "usertypeid", unique = true, nullable = false)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import java.util.Currency;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@Entity
|
||||
public class ESomeType {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
Currency currency;
|
||||
|
||||
Locale locale;
|
||||
|
||||
TimeZone timeZone;
|
||||
|
||||
public String toString() {
|
||||
return id + " " + locale + " " + currency + " " + timeZone;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Currency getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(Currency currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public TimeZone getTimeZone() {
|
||||
return timeZone;
|
||||
}
|
||||
|
||||
public void setTimeZone(TimeZone timeZone) {
|
||||
this.timeZone = timeZone;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Transient;
|
||||
import java.util.Map;
|
||||
|
||||
@Entity
|
||||
public class ETransMany {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
@Transient
|
||||
Map<String, String> transMap;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Map<String, String> getTransMap() {
|
||||
return transMap;
|
||||
}
|
||||
|
||||
public void setTransMap(Map<String, String> transMap) {
|
||||
this.transMap = transMap;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class EVanillaCollection {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToMany(cascade = CascadeType.PERSIST)
|
||||
List<EVanillaCollectionDetail> details;
|
||||
|
||||
public EVanillaCollection() {
|
||||
details = new ArrayList<>();
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<EVanillaCollectionDetail> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public void setDetails(List<EVanillaCollectionDetail> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class EVanillaCollectionDetail {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String something;
|
||||
|
||||
public EVanillaCollectionDetail() {
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import java.net.InetAddress;
|
||||
|
||||
@Entity
|
||||
@Table(name = "e_withinet")
|
||||
public class EWithInetAddr {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
String name;
|
||||
|
||||
InetAddress inetAddress;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public InetAddress getInetAddress() {
|
||||
return inetAddress;
|
||||
}
|
||||
|
||||
public void setInetAddress(InetAddress inetAddress) {
|
||||
this.inetAddress = inetAddress;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Cache(readOnly = true)
|
||||
@Entity
|
||||
@Table(name = "feature_desc")
|
||||
public class FeatureDescription {
|
||||
|
||||
@Id
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToMany;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@DiscriminatorValue("1")
|
||||
public class ListAttribute extends Attribute {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ManyToMany(mappedBy = "listAttributes", cascade = {CascadeType.PERSIST})
|
||||
private Set<ListAttributeValue> values;// = new HashSet<ListAttributeValue>();
|
||||
// Do not define this as a HashSet so that it is left up to Ebean
|
||||
// to define it as a BeanSet ... and hence aware of M2M modify changes
|
||||
// Put this back to HashSet and Duplicate Key Exception will return
|
||||
|
||||
public Set<ListAttributeValue> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(Set<ListAttributeValue> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public void add(ListAttributeValue value) {
|
||||
getValues().add(value);
|
||||
value.getListAttributes().add(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name = "la_attr_value")
|
||||
public class ListAttributeValue extends BasicDomain {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
|
||||
@ManyToMany
|
||||
private Set<ListAttribute> listAttributes;
|
||||
|
||||
public Set<ListAttribute> getListAttributes() {
|
||||
return listAttributes;
|
||||
}
|
||||
|
||||
public void setListAttribute(Set<ListAttribute> listAttributes) {
|
||||
this.listAttributes = listAttributes;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
public enum MNonEnum {
|
||||
|
||||
BEGIN("B"),
|
||||
END("E");
|
||||
|
||||
String value;
|
||||
|
||||
MNonEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "non_updateprop")
|
||||
public class MNonUpdPropEntity {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
MNonEnum nonEnum;
|
||||
|
||||
@Column(updatable = false)
|
||||
String name;
|
||||
|
||||
String note;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public MNonEnum getNonEnum() {
|
||||
return nonEnum;
|
||||
}
|
||||
|
||||
public void setNonEnum(MNonEnum nonEnum) {
|
||||
this.nonEnum = nonEnum;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class MProtectedConstructBean {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
// private MProtectedConstructBean() {
|
||||
//
|
||||
// }
|
||||
|
||||
public MProtectedConstructBean(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "mrole")
|
||||
public class MRole {
|
||||
|
||||
@Id
|
||||
Integer roleid;
|
||||
|
||||
String roleName;
|
||||
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
List<MUser> users;
|
||||
|
||||
public MRole() {
|
||||
|
||||
}
|
||||
|
||||
public MRole(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public Integer getRoleid() {
|
||||
return roleid;
|
||||
}
|
||||
|
||||
public void setRoleid(Integer roleid) {
|
||||
this.roleid = roleid;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public List<MUser> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(List<MUser> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MRole [roleName=" + roleName + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Make sure other is not null and has the same class as this
|
||||
if (other != null && getClass().equals(other.getClass())) {
|
||||
final MRole rhs = (MRole) other;
|
||||
if (roleid.equals(rhs.roleid)) {
|
||||
if (roleid == 0) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (roleid != null && roleid != 0) {
|
||||
int rid = roleid;
|
||||
return (int) (rid ^ (rid >>> 32));
|
||||
}
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "muser")
|
||||
public class MUser {
|
||||
|
||||
@Id
|
||||
Integer userid;
|
||||
|
||||
String userName;
|
||||
|
||||
// Cascade remove will delete from intersection table
|
||||
// but will not delete the actual Roles
|
||||
@ManyToMany(mappedBy = "users", cascade = CascadeType.ALL)
|
||||
List<MRole> roles;
|
||||
|
||||
@ManyToOne
|
||||
private MUserType userType;
|
||||
|
||||
public MUser() {
|
||||
|
||||
}
|
||||
|
||||
public MUser(List<MRole> startRoles) {
|
||||
this.roles.addAll(startRoles);
|
||||
}
|
||||
|
||||
public MUser(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public Integer getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(Integer userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public List<MRole> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(List<MRole> roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public void addRole(MRole role) {
|
||||
if (roles == null) {
|
||||
roles = new ArrayList<>();
|
||||
}
|
||||
roles.add(role);
|
||||
}
|
||||
|
||||
public MUserType getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(MUserType userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "muser_type")
|
||||
public class MUserType {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
public MUserType() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MUserType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
public class MnocRole {
|
||||
|
||||
@Id
|
||||
Integer roleId;
|
||||
|
||||
String roleName;
|
||||
|
||||
@Version
|
||||
Integer version;
|
||||
|
||||
public MnocRole() {
|
||||
|
||||
}
|
||||
|
||||
public MnocRole(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public Integer getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Integer roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return roleName;
|
||||
}
|
||||
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.OrderBy;
|
||||
import javax.persistence.Version;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class MnocUser {
|
||||
|
||||
@Id
|
||||
Integer userId;
|
||||
|
||||
String userName;
|
||||
|
||||
@Version
|
||||
Integer version;
|
||||
|
||||
// No cascade REMOVE
|
||||
@ManyToMany(cascade = CascadeType.PERSIST)
|
||||
@OrderBy("roleName")
|
||||
List<MnocRole> validRoles;
|
||||
|
||||
public MnocUser() {
|
||||
|
||||
}
|
||||
|
||||
public MnocUser(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer roleId) {
|
||||
this.userId = roleId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String roleName) {
|
||||
this.userName = roleName;
|
||||
}
|
||||
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public List<MnocRole> getValidRoles() {
|
||||
return validRoles;
|
||||
}
|
||||
|
||||
public void setValidRoles(List<MnocRole> validRoles) {
|
||||
this.validRoles = validRoles;
|
||||
}
|
||||
|
||||
public void addValidRole(MnocRole role) {
|
||||
if (validRoles == null) {
|
||||
validRoles = new ArrayList<>();
|
||||
}
|
||||
validRoles.add(role);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Sql;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
@Sql
|
||||
public class MyAdHoc {
|
||||
|
||||
@ManyToOne
|
||||
Order order;
|
||||
|
||||
int detailCount;
|
||||
|
||||
public Order getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(Order order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public int getDetailCount() {
|
||||
return detailCount;
|
||||
}
|
||||
|
||||
public void setDetailCount(int detailCount) {
|
||||
this.detailCount = detailCount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.config.ServerConfig;
|
||||
import io.ebean.event.AbstractBeanPersistListener;
|
||||
import io.ebean.event.BulkTableEvent;
|
||||
import io.ebean.event.BulkTableEventListener;
|
||||
import io.ebean.event.ServerConfigStartup;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
public class MyEBasicConfigStartup implements ServerConfigStartup {
|
||||
|
||||
public static final AtomicLong insertCount = new AtomicLong();
|
||||
public static final AtomicLong updateCount = new AtomicLong();
|
||||
public static final AtomicLong deleteCount = new AtomicLong();
|
||||
|
||||
public static void resetCounters() {
|
||||
insertCount.set(0);
|
||||
updateCount.set(0);
|
||||
deleteCount.set(0);
|
||||
}
|
||||
|
||||
public void onStart(ServerConfig serverConfig) {
|
||||
|
||||
serverConfig.add(new EbasicPersistList());
|
||||
serverConfig.add(new EbasicBulkListener());
|
||||
}
|
||||
|
||||
public static class EbasicBulkListener implements BulkTableEventListener {
|
||||
|
||||
final Set<String> s = new HashSet<>();
|
||||
|
||||
EbasicBulkListener() {
|
||||
s.add("e_basic");
|
||||
}
|
||||
|
||||
public Set<String> registeredTables() {
|
||||
return s;
|
||||
}
|
||||
|
||||
public void process(BulkTableEvent bulkTableEvent) {
|
||||
System.out.println("-- " + bulkTableEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class EbasicPersistList extends AbstractBeanPersistListener {
|
||||
|
||||
@Override
|
||||
public boolean isRegisterFor(Class<?> cls) {
|
||||
return EBasic.class.isAssignableFrom(cls);
|
||||
}
|
||||
|
||||
public void inserted(Object bean) {
|
||||
insertCount.incrementAndGet();
|
||||
System.out.println("-- EBasic inserted " + ((EBasic) bean).getId());
|
||||
}
|
||||
|
||||
public void updated(Object bean, Set<String> updatedProperties) {
|
||||
updateCount.incrementAndGet();
|
||||
System.out.println("-- EBasic updated " + ((EBasic) bean).getId() + " updatedProperties: " + updatedProperties);
|
||||
}
|
||||
|
||||
public void deleted(Object bean) {
|
||||
deleteCount.incrementAndGet();
|
||||
System.out.println("-- EBasic deleted " + ((EBasic) bean).getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class MyLobSize {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
int myCount;
|
||||
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
@Lob
|
||||
//@Length(max=65535)
|
||||
//@Length(max=65536)
|
||||
String myLob;
|
||||
|
||||
@OneToMany(mappedBy = "parent")
|
||||
List<MyLobSizeJoinMany> details;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMyLob() {
|
||||
return myLob;
|
||||
}
|
||||
|
||||
public void setMyLob(String myLob) {
|
||||
this.myLob = myLob;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getMyCount() {
|
||||
return myCount;
|
||||
}
|
||||
|
||||
public void setMyCount(int myCount) {
|
||||
this.myCount = myCount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class MyLobSizeJoinMany {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@Basic(fetch = FetchType.LAZY)
|
||||
String something;
|
||||
|
||||
String other;
|
||||
|
||||
@ManyToOne
|
||||
MyLobSize parent;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSomething() {
|
||||
return something;
|
||||
}
|
||||
|
||||
public void setSomething(String something) {
|
||||
this.something = something;
|
||||
}
|
||||
|
||||
public String getOther() {
|
||||
return other;
|
||||
}
|
||||
|
||||
public void setOther(String other) {
|
||||
this.other = other;
|
||||
}
|
||||
|
||||
public MyLobSize getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(MyLobSize parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Cached bean for testing caching implementation.
|
||||
*/
|
||||
@Cache
|
||||
@Entity
|
||||
@Table(name = "o_cached_bean")
|
||||
public class OCachedBean {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
String name;
|
||||
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
List<Country> countries = new ArrayList<>();
|
||||
|
||||
@OneToMany(mappedBy = "cachedBean", cascade = CascadeType.ALL)
|
||||
List<OCachedBeanChild> children = new ArrayList<>();
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<Country> getCountries() {
|
||||
return countries;
|
||||
}
|
||||
|
||||
public void setCountries(List<Country> countries) {
|
||||
this.countries = countries;
|
||||
}
|
||||
|
||||
public List<OCachedBeanChild> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<OCachedBeanChild> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* Cached bean for testing caching implementation, especially relations.
|
||||
*/
|
||||
@Cache
|
||||
@Entity
|
||||
@Table(name = "o_cached_bean_child")
|
||||
public class OCachedBeanChild {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@ManyToOne
|
||||
OCachedBean cachedBean;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public OCachedBean getCachedBean() {
|
||||
return cachedBean;
|
||||
}
|
||||
|
||||
public void setCachedBean(OCachedBean cachedBean) {
|
||||
this.cachedBean = cachedBean;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class OCar extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String vin;
|
||||
|
||||
private String name;
|
||||
|
||||
@OneToOne(mappedBy = "car", cascade = CascadeType.ALL)
|
||||
private OGearBox gearBox;
|
||||
|
||||
@OneToOne(mappedBy = "car", cascade = CascadeType.ALL)
|
||||
private OEngine engine;
|
||||
|
||||
public OCar() {
|
||||
}
|
||||
|
||||
public OCar(String vin, String name) {
|
||||
super();
|
||||
this.vin = vin;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getVin() {
|
||||
return vin;
|
||||
}
|
||||
|
||||
public void setVin(String vin) {
|
||||
this.vin = vin;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public OGearBox getGearBox() {
|
||||
return gearBox;
|
||||
}
|
||||
|
||||
public void setGearBox(OGearBox gearBox) {
|
||||
this.gearBox = gearBox;
|
||||
gearBox.setCar(this);
|
||||
}
|
||||
|
||||
public OEngine getEngine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
public void setEngine(OEngine engine) {
|
||||
this.engine = engine;
|
||||
engine.setCar(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Version;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
public class OEngine {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private UUID engineId;
|
||||
|
||||
private String shortDesc;
|
||||
|
||||
@Version
|
||||
private Integer version;
|
||||
|
||||
@OneToOne
|
||||
private OCar car;
|
||||
|
||||
public OEngine() {
|
||||
}
|
||||
|
||||
public UUID getEngineId() {
|
||||
return engineId;
|
||||
}
|
||||
|
||||
public void setEngineId(UUID engineId) {
|
||||
this.engineId = engineId;
|
||||
}
|
||||
|
||||
public String getShortDesc() {
|
||||
return shortDesc;
|
||||
}
|
||||
|
||||
public void setShortDesc(String shortDesc) {
|
||||
this.shortDesc = shortDesc;
|
||||
}
|
||||
|
||||
public OCar getCar() {
|
||||
return car;
|
||||
}
|
||||
|
||||
public void setCar(OCar car) {
|
||||
this.car = car;
|
||||
}
|
||||
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Version;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
public class OGearBox {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
private UUID id;
|
||||
|
||||
private String boxDesc;
|
||||
|
||||
@Column(name = "box_size")
|
||||
private Integer size;
|
||||
|
||||
@Version
|
||||
private Integer version;
|
||||
|
||||
@OneToOne
|
||||
private OCar car;
|
||||
|
||||
public OGearBox() {
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getBoxDesc() {
|
||||
return boxDesc;
|
||||
}
|
||||
|
||||
public void setBoxDesc(String boxDesc) {
|
||||
this.boxDesc = boxDesc;
|
||||
}
|
||||
|
||||
public Integer getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Integer size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public OCar getCar() {
|
||||
return car;
|
||||
}
|
||||
|
||||
public void setCar(OCar car) {
|
||||
this.car = car;
|
||||
}
|
||||
|
||||
public Integer getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Integer version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.ChangeLog;
|
||||
import io.ebean.annotation.DocEmbedded;
|
||||
import io.ebean.annotation.DocStore;
|
||||
import io.ebean.annotation.Formula;
|
||||
import io.ebean.annotation.WhenCreated;
|
||||
import io.ebean.annotation.Where;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderBy;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import javax.persistence.Version;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Order entity bean.
|
||||
*/
|
||||
@Cache
|
||||
@DocStore
|
||||
@ChangeLog
|
||||
@Entity
|
||||
@Table(name = "o_order")
|
||||
public class Order implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public enum Status {
|
||||
NEW,
|
||||
APPROVED,
|
||||
SHIPPED,
|
||||
COMPLETE
|
||||
}
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
/**
|
||||
* Derived total amount from the order details. Needs to be explicitly included in query as Transient.
|
||||
* Removing the Transient would mean by default it would be included in a order query.
|
||||
* <p>
|
||||
* NOTE: The join clause for totalAmount and totalItems is the same. If your query includes both
|
||||
* totalAmount and totalItems only the one join is added to the query.
|
||||
* </p>
|
||||
*/
|
||||
@Transient
|
||||
@Formula(
|
||||
select = "z_b${ta}.total_amount",
|
||||
join = "join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_b${ta} on z_b${ta}.order_id = ${ta}.id")
|
||||
Double totalAmount;
|
||||
|
||||
/**
|
||||
* Derived total item count from the order details. Needs to be explicitly included in query as Transient.
|
||||
*/
|
||||
@Transient
|
||||
@Formula(
|
||||
select = "z_b${ta}.total_items",
|
||||
join = "join (select order_id, count(*) as total_items, sum(order_qty*unit_price) as total_amount from o_order_detail group by order_id) z_b${ta} on z_b${ta}.order_id = ${ta}.id")
|
||||
Integer totalItems;
|
||||
|
||||
@Enumerated(value = EnumType.ORDINAL)
|
||||
Status status = Status.NEW;
|
||||
|
||||
Date orderDate = new Date(System.currentTimeMillis());
|
||||
|
||||
Date shipDate;
|
||||
|
||||
@NotNull
|
||||
@ManyToOne(cascade = CascadeType.PERSIST)
|
||||
@JoinColumn(name = "kcustomer_id")
|
||||
@DocEmbedded(doc = "id,name")
|
||||
Customer customer;
|
||||
|
||||
@Column(name = "name", table = "o_customer")
|
||||
String customerName;
|
||||
|
||||
@WhenCreated
|
||||
Timestamp cretime;
|
||||
|
||||
@Version
|
||||
Timestamp updtime;
|
||||
|
||||
@Where(clause = "${ta}.id > 0")
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order")
|
||||
@OrderBy("id asc, orderQty asc, cretime desc")
|
||||
@DocEmbedded
|
||||
List<OrderDetail> details;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "order")
|
||||
List<OrderShipment> shipments;
|
||||
|
||||
public String toString() {
|
||||
return id + " totalAmount:" + totalAmount + " totalItems:" + totalItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return id.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id.
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
public Double getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
public void setTotalAmount(Double totalAmount) {
|
||||
this.totalAmount = totalAmount;
|
||||
}
|
||||
|
||||
public Integer getTotalItems() {
|
||||
return totalItems;
|
||||
}
|
||||
|
||||
public void setTotalItems(Integer totalItems) {
|
||||
this.totalItems = totalItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return order date.
|
||||
*/
|
||||
public Date getOrderDate() {
|
||||
return orderDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order date.
|
||||
*/
|
||||
public void setOrderDate(Date orderDate) {
|
||||
this.orderDate = orderDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ship date.
|
||||
*/
|
||||
public Date getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ship date.
|
||||
*/
|
||||
public void setShipDate(Date shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cretime.
|
||||
*/
|
||||
public Timestamp getCretime() {
|
||||
return cretime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cretime.
|
||||
*/
|
||||
public void setCretime(Timestamp cretime) {
|
||||
this.cretime = cretime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return updtime.
|
||||
*/
|
||||
public Timestamp getUpdtime() {
|
||||
return updtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set updtime.
|
||||
*/
|
||||
public void setUpdtime(Timestamp updtime) {
|
||||
this.updtime = updtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return status.
|
||||
*/
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set status.
|
||||
*/
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return customer.
|
||||
*/
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set customer.
|
||||
*/
|
||||
public void setCustomer(Customer customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return details.
|
||||
*/
|
||||
public List<OrderDetail> getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set details.
|
||||
*/
|
||||
public void setDetails(List<OrderDetail> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public void addDetail(OrderDetail detail) {
|
||||
|
||||
if (details == null) {
|
||||
details = new ArrayList<>();
|
||||
}
|
||||
details.add(detail);
|
||||
}
|
||||
|
||||
public List<OrderShipment> getShipments() {
|
||||
return shipments;
|
||||
}
|
||||
|
||||
public void setShipments(List<OrderShipment> shipments) {
|
||||
this.shipments = shipments;
|
||||
}
|
||||
|
||||
public void addShipment(OrderShipment shipment) {
|
||||
|
||||
if (shipments == null) {
|
||||
shipments = new ArrayList<>();
|
||||
}
|
||||
shipments.add(shipment);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Sql;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
/**
|
||||
* An example of an Aggregate object.
|
||||
* <p>
|
||||
* Note the @Sql indicates to Ebean that this bean is not based on a table but
|
||||
* instead uses RawSql.
|
||||
* </p>
|
||||
*/
|
||||
@Entity
|
||||
@Sql
|
||||
public class OrderAggregate {
|
||||
|
||||
@OneToOne
|
||||
Order order;
|
||||
|
||||
Double maxAmount;
|
||||
|
||||
Double totalAmount;
|
||||
|
||||
Long totalItems;
|
||||
|
||||
public String toString() {
|
||||
return order.getId() + " totalAmount:" + totalAmount + " totalItems:" + totalItems;
|
||||
}
|
||||
|
||||
public Order getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(Order order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
public Double getTotalAmount() {
|
||||
return totalAmount;
|
||||
}
|
||||
|
||||
public void setTotalAmount(Double totalAmount) {
|
||||
this.totalAmount = totalAmount;
|
||||
}
|
||||
|
||||
public Long getTotalItems() {
|
||||
return totalItems;
|
||||
}
|
||||
|
||||
public void setTotalItems(Long totalItems) {
|
||||
this.totalItems = totalItems;
|
||||
}
|
||||
|
||||
public Double getMaxAmount() {
|
||||
return maxAmount;
|
||||
}
|
||||
|
||||
public void setMaxAmount(Double maxAmount) {
|
||||
this.maxAmount = maxAmount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.DocEmbedded;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Order Detail entity bean.
|
||||
*/
|
||||
@Cache
|
||||
@Entity
|
||||
@Table(name = "o_order_detail")
|
||||
public class OrderDetail implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
Order order;
|
||||
|
||||
Integer orderQty;
|
||||
|
||||
Integer shipQty;
|
||||
|
||||
Double unitPrice;
|
||||
|
||||
@ManyToOne
|
||||
@DocEmbedded(doc = "id,name,sku")
|
||||
Product product;
|
||||
|
||||
Timestamp cretime;
|
||||
|
||||
@Version
|
||||
Timestamp updtime;
|
||||
|
||||
public OrderDetail() {
|
||||
}
|
||||
|
||||
public OrderDetail(Product product, Integer orderQty, Double unitPrice) {
|
||||
this.product = product;
|
||||
this.orderQty = orderQty;
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return id.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id.
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return order qty.
|
||||
*/
|
||||
public Integer getOrderQty() {
|
||||
return orderQty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order qty.
|
||||
*/
|
||||
public void setOrderQty(Integer orderQty) {
|
||||
this.orderQty = orderQty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return ship qty.
|
||||
*/
|
||||
public Integer getShipQty() {
|
||||
return shipQty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ship qty.
|
||||
*/
|
||||
public void setShipQty(Integer shipQty) {
|
||||
this.shipQty = shipQty;
|
||||
}
|
||||
|
||||
public Double getUnitPrice() {
|
||||
return unitPrice;
|
||||
}
|
||||
|
||||
public void setUnitPrice(Double unitPrice) {
|
||||
this.unitPrice = unitPrice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cretime.
|
||||
*/
|
||||
public Timestamp getCretime() {
|
||||
return cretime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cretime.
|
||||
*/
|
||||
public void setCretime(Timestamp cretime) {
|
||||
this.cretime = cretime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return updtime.
|
||||
*/
|
||||
public Timestamp getUpdtime() {
|
||||
return updtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set updtime.
|
||||
*/
|
||||
public void setUpdtime(Timestamp updtime) {
|
||||
this.updtime = updtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return order.
|
||||
*/
|
||||
public Order getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order.
|
||||
*/
|
||||
public void setOrder(Order order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return product.
|
||||
*/
|
||||
public Product getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set product.
|
||||
*/
|
||||
public void setProduct(Product product) {
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "or_order_ship")
|
||||
public class OrderShipment extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ManyToOne
|
||||
private Order order;
|
||||
|
||||
private Timestamp shipTime = new Timestamp(System.currentTimeMillis());
|
||||
|
||||
public Timestamp getShipTime() {
|
||||
return shipTime;
|
||||
}
|
||||
|
||||
public void setShipTime(Timestamp shipTime) {
|
||||
this.shipTime = shipTime;
|
||||
}
|
||||
|
||||
public Order getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
public void setOrder(Order order) {
|
||||
this.order = order;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class PFile extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
private PFileContent fileContent;
|
||||
|
||||
/**
|
||||
* Another persistent file.
|
||||
*/
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
private PFileContent fileContent2;
|
||||
|
||||
public PFile() {
|
||||
}
|
||||
|
||||
public PFile(String name, PFileContent fileContent) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.fileContent = fileContent;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public PFileContent getFileContent() {
|
||||
return fileContent;
|
||||
}
|
||||
|
||||
public void setFileContent(PFileContent fileContent) {
|
||||
this.fileContent = fileContent;
|
||||
}
|
||||
|
||||
public PFileContent getFileContent2() {
|
||||
return fileContent2;
|
||||
}
|
||||
|
||||
public void setFileContent2(PFileContent fileContent2) {
|
||||
this.fileContent2 = fileContent2;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Lob;
|
||||
|
||||
@Entity
|
||||
public class PFileContent extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The content.
|
||||
*/
|
||||
@Lob
|
||||
private byte[] content;
|
||||
|
||||
public PFileContent() {
|
||||
}
|
||||
|
||||
public PFileContent(byte[] content) {
|
||||
super();
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public byte[] getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(byte[] content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class PersistentFile extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
|
||||
@OneToOne(mappedBy = "persistentFile", cascade = CascadeType.ALL)
|
||||
private PersistentFileContent persistentFileContent;
|
||||
|
||||
public PersistentFile() {
|
||||
}
|
||||
|
||||
public PersistentFile(String name,
|
||||
PersistentFileContent persistentFileContent) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.persistentFileContent = persistentFileContent;
|
||||
|
||||
this.persistentFileContent.setPersistentFile(this);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public PersistentFileContent getPersistentFileContent() {
|
||||
return persistentFileContent;
|
||||
}
|
||||
|
||||
public void setPersistentFileContent(PersistentFileContent persistentFileContent) {
|
||||
this.persistentFileContent = persistentFileContent;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class PersistentFileContent extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The persistent file.
|
||||
*/
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
private PersistentFile persistentFile;
|
||||
|
||||
/**
|
||||
* The content.
|
||||
*/
|
||||
@Lob
|
||||
private byte[] content;
|
||||
|
||||
public PersistentFileContent() {
|
||||
}
|
||||
|
||||
public PersistentFileContent(byte[] content) {
|
||||
super();
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public PersistentFile getPersistentFile() {
|
||||
return persistentFile;
|
||||
}
|
||||
|
||||
public void setPersistentFile(PersistentFile persistentFile) {
|
||||
this.persistentFile = persistentFile;
|
||||
}
|
||||
|
||||
public byte[] getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(byte[] content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.SequenceGenerator;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Entity(name = "Person")
|
||||
@Table(name = "PERSONS")
|
||||
public class Person implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 495045977245770183L;
|
||||
|
||||
private Long id;
|
||||
private String surname;
|
||||
private String name;
|
||||
private List<Phone> phones;
|
||||
|
||||
public Person() {
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = javax.persistence.GenerationType.AUTO)
|
||||
@SequenceGenerator(name = "PERSONS_SEQ", initialValue = 1000, allocationSize = 40)
|
||||
@Column(name = "ID", unique = true, nullable = false)
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "SURNAME", nullable = false, unique = false, columnDefinition = "varchar(64)")
|
||||
public String getSurname() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
public void setSurname(String surname) {
|
||||
this.surname = surname;
|
||||
}
|
||||
|
||||
@Column(name = "NAME", nullable = false, unique = false, columnDefinition = "varchar(64)")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@OneToMany(targetEntity = Phone.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "person")
|
||||
public List<Phone> getPhones() {
|
||||
return phones;
|
||||
}
|
||||
|
||||
public void setPhones(List<Phone> phones) {
|
||||
this.phones = phones;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Entity(name = "Phone")
|
||||
@Table(name = "PHONES")
|
||||
public class Phone implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -326610269092956952L;
|
||||
|
||||
private Long id;
|
||||
private String phoneNumber;
|
||||
private Person person;
|
||||
|
||||
public Phone() {
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = javax.persistence.GenerationType.AUTO)
|
||||
@Column(name = "ID", unique = true, nullable = false)
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Column(name = "PHONE_NUMBER", nullable = false, unique = true, columnDefinition = "varchar(7)")
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@ManyToOne(targetEntity = Person.class, cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "PERSON_ID", nullable = false)
|
||||
public Person getPerson() {
|
||||
return person;
|
||||
}
|
||||
|
||||
public void setPerson(Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
import io.ebean.annotation.CacheQueryTuning;
|
||||
import io.ebean.annotation.CreatedTimestamp;
|
||||
import io.ebean.annotation.DocStore;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* Product entity bean.
|
||||
*/
|
||||
@DocStore
|
||||
@Cache
|
||||
@CacheQueryTuning(maxSecsToLive = 15)
|
||||
@Entity
|
||||
@Table(name = "o_product")
|
||||
public class Product implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@Size(max = 20)
|
||||
String sku;
|
||||
|
||||
String name;
|
||||
|
||||
@CreatedTimestamp
|
||||
Timestamp cretime;
|
||||
|
||||
@Version
|
||||
Timestamp updtime;
|
||||
|
||||
/**
|
||||
* Return id.
|
||||
*/
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set id.
|
||||
*/
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return sku.
|
||||
*/
|
||||
public String getSku() {
|
||||
return sku;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set sku.
|
||||
*/
|
||||
public void setSku(String sku) {
|
||||
this.sku = sku;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cretime.
|
||||
*/
|
||||
public Timestamp getCretime() {
|
||||
return cretime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cretime.
|
||||
*/
|
||||
public void setCretime(Timestamp cretime) {
|
||||
this.cretime = cretime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return updtime.
|
||||
*/
|
||||
public Timestamp getUpdtime() {
|
||||
return updtime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set updtime.
|
||||
*/
|
||||
public void setUpdtime(Timestamp updtime) {
|
||||
this.updtime = updtime;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.EbeanServer;
|
||||
import org.tests.model.basic.Order.Status;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ResetBasicData {
|
||||
|
||||
private static boolean runOnce;
|
||||
|
||||
private static EbeanServer server = Ebean.getServer(null);
|
||||
|
||||
public static synchronized void reset() {
|
||||
|
||||
if (runOnce) {
|
||||
return;
|
||||
}
|
||||
|
||||
final ResetBasicData me = new ResetBasicData();
|
||||
|
||||
server.execute(() -> {
|
||||
if (server.find(Product.class).findCount() > 0) {
|
||||
// we can't really delete this base data as
|
||||
// the test rely on the products being in there
|
||||
return;
|
||||
}
|
||||
//me.deleteAll();
|
||||
me.insertCountries();
|
||||
me.insertProducts();
|
||||
me.insertTestCustAndOrders();
|
||||
});
|
||||
runOnce = true;
|
||||
}
|
||||
|
||||
|
||||
public void deleteAll() {
|
||||
Ebean.execute(() -> {
|
||||
|
||||
// orm update use bean name and bean properties
|
||||
server.createSqlUpdate("delete from o_cached_bean_child").execute();
|
||||
server.createSqlUpdate("delete from o_cached_bean_country").execute();
|
||||
server.createSqlUpdate("delete from o_cached_bean").execute();
|
||||
|
||||
server.createUpdate(OrderShipment.class, "delete from orderShipment").execute();
|
||||
|
||||
server.createUpdate(OrderDetail.class, "delete from orderDetail").execute();
|
||||
|
||||
server.createUpdate(Order.class, "delete from order").execute();
|
||||
|
||||
server.createUpdate(Contact.class, "delete from contact").execute();
|
||||
|
||||
server.createUpdate(Customer.class, "delete from Customer").execute();
|
||||
|
||||
server.createUpdate(Address.class, "delete from address").execute();
|
||||
|
||||
// sql update uses table and column names
|
||||
server.createSqlUpdate("delete from o_country").execute();
|
||||
server.createSqlUpdate("delete from o_product").execute();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void insertCountries() {
|
||||
|
||||
if (server.find(Country.class).findCount() > 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
server.execute(() -> {
|
||||
Country c = new Country();
|
||||
c.setCode("NZ");
|
||||
c.setName("New Zealand");
|
||||
server.save(c);
|
||||
|
||||
Country au = new Country();
|
||||
au.setCode("AU");
|
||||
au.setName("Australia");
|
||||
server.save(au);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void insertProducts() {
|
||||
|
||||
if (server.find(Product.class).findCount() > 0) {
|
||||
return;
|
||||
}
|
||||
server.execute(() -> {
|
||||
Product p = new Product();
|
||||
p.setName("Chair");
|
||||
p.setSku("C001");
|
||||
server.save(p);
|
||||
|
||||
p = new Product();
|
||||
p.setName("Desk");
|
||||
p.setSku("DSK1");
|
||||
server.save(p);
|
||||
|
||||
p = new Product();
|
||||
p.setName("Computer");
|
||||
p.setSku("C002");
|
||||
server.save(p);
|
||||
|
||||
p = new Product();
|
||||
p.setName("Printer");
|
||||
p.setSku("C003");
|
||||
server.save(p);
|
||||
});
|
||||
}
|
||||
|
||||
public void insertTestCustAndOrders() {
|
||||
|
||||
Ebean.execute(() -> {
|
||||
Customer cust1 = insertCustomer("Rob");
|
||||
Customer cust2 = insertCustomerNoAddress();
|
||||
insertCustomerFiona();
|
||||
insertCustomerNoContacts("NocCust");
|
||||
|
||||
createOrder1(cust1);
|
||||
createOrder2(cust2);
|
||||
createOrder3(cust1);
|
||||
createOrder4(cust1);
|
||||
createOrder5(cust2);
|
||||
});
|
||||
}
|
||||
|
||||
public static Customer createCustAndOrder(String custName) {
|
||||
|
||||
ResetBasicData me = new ResetBasicData();
|
||||
Customer cust1 = insertCustomer(custName);
|
||||
me.createOrder1(cust1);
|
||||
return cust1;
|
||||
}
|
||||
|
||||
public static Order createOrderCustAndOrder(String custName) {
|
||||
|
||||
ResetBasicData me = new ResetBasicData();
|
||||
Customer cust1 = insertCustomer(custName);
|
||||
return me.createOrder1(cust1);
|
||||
}
|
||||
|
||||
private static int contactEmailNum = 1;
|
||||
|
||||
private Customer insertCustomerFiona() {
|
||||
|
||||
Customer c = createCustomer("Fiona", "12 Apple St", "West Coast Rd", 1, "2009-08-31");
|
||||
c.setStatus(Customer.Status.ACTIVE);
|
||||
|
||||
c.addContact(createContact("Fiona", "Black"));
|
||||
c.addContact(createContact("Tracy", "Red"));
|
||||
|
||||
Ebean.save(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
public static Contact createContact(String firstName, String lastName) {
|
||||
Contact contact = new Contact(firstName, lastName);
|
||||
String email = contact.getLastName() + (contactEmailNum++) + "@test.com";
|
||||
contact.setEmail(email.toLowerCase());
|
||||
return contact;
|
||||
}
|
||||
|
||||
private Customer insertCustomerNoContacts(String name) {
|
||||
|
||||
Customer c = createCustomer("Roger", "15 Kumera Way", "Bos town", 1, "2010-04-10");
|
||||
c.setName(name);
|
||||
c.setStatus(Customer.Status.ACTIVE);
|
||||
|
||||
Ebean.save(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
private Customer insertCustomerNoAddress() {
|
||||
|
||||
Customer c = new Customer();
|
||||
c.setName("Cust NoAddress");
|
||||
c.setStatus(Customer.Status.NEW);
|
||||
c.addContact(createContact("Jack", "Black"));
|
||||
|
||||
Ebean.save(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
private static Customer insertCustomer(String name) {
|
||||
Customer c = createCustomer(name, "1 Banana St", "P.O.Box 1234", 1, null);
|
||||
Ebean.save(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
public static Customer createCustomer(String name, String shippingStreet, String billingStreet, int contactSuffix) {
|
||||
return createCustomer(name, shippingStreet, billingStreet, contactSuffix, null);
|
||||
}
|
||||
|
||||
public static Customer createCustomer(String name, String shippingStreet, String billingStreet, int contactSuffix, String annDate) {
|
||||
|
||||
Customer c = new Customer();
|
||||
c.setName(name);
|
||||
c.setStatus(Customer.Status.NEW);
|
||||
if (annDate == null) {
|
||||
annDate = "2010-04-14";
|
||||
}
|
||||
c.setAnniversary(Date.valueOf(annDate));
|
||||
if (contactSuffix > 0) {
|
||||
Contact jim = new Contact("Jim" + contactSuffix, "Cricket");
|
||||
jim.getNotes().add(new ContactNote("ORM Lives", "And it is cool!"));
|
||||
c.addContact(jim);
|
||||
c.addContact(new Contact("Fred" + contactSuffix, "Blue"));
|
||||
c.addContact(new Contact("Bugs" + contactSuffix, "Bunny"));
|
||||
}
|
||||
|
||||
if (shippingStreet != null) {
|
||||
Address shippingAddr = new Address();
|
||||
shippingAddr.setLine1(shippingStreet);
|
||||
shippingAddr.setLine2("Sandringham");
|
||||
shippingAddr.setCity("Auckland");
|
||||
shippingAddr.setCountry(Ebean.getReference(Country.class, "NZ"));
|
||||
|
||||
c.setShippingAddress(shippingAddr);
|
||||
}
|
||||
|
||||
if (billingStreet != null) {
|
||||
Address billingAddr = new Address();
|
||||
billingAddr.setLine1(billingStreet);
|
||||
billingAddr.setLine2("St Lukes");
|
||||
billingAddr.setCity("Auckland");
|
||||
billingAddr.setCountry(Ebean.getReference(Country.class, "NZ"));
|
||||
|
||||
c.setBillingAddress(billingAddr);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
private Order createOrder1(Customer customer) {
|
||||
|
||||
Product product1 = Ebean.getReference(Product.class, 1);
|
||||
Product product2 = Ebean.getReference(Product.class, 2);
|
||||
Product product3 = Ebean.getReference(Product.class, 3);
|
||||
|
||||
|
||||
Order order = new Order();
|
||||
order.setCustomer(customer);
|
||||
|
||||
List<OrderDetail> details = new ArrayList<>();
|
||||
details.add(new OrderDetail(product1, 5, 10.50));
|
||||
details.add(new OrderDetail(product2, 3, 1.10));
|
||||
details.add(new OrderDetail(product3, 1, 2.00));
|
||||
order.setDetails(details);
|
||||
|
||||
|
||||
order.addShipment(new OrderShipment());
|
||||
|
||||
Ebean.save(order);
|
||||
return order;
|
||||
}
|
||||
|
||||
private void createOrder2(Customer customer) {
|
||||
|
||||
Product product1 = Ebean.getReference(Product.class, 1);
|
||||
|
||||
Order order = new Order();
|
||||
order.setStatus(Status.SHIPPED);
|
||||
order.setCustomer(customer);
|
||||
|
||||
List<OrderDetail> details = new ArrayList<>();
|
||||
details.add(new OrderDetail(product1, 4, 10.50));
|
||||
order.setDetails(details);
|
||||
|
||||
order.addShipment(new OrderShipment());
|
||||
|
||||
Ebean.save(order);
|
||||
}
|
||||
|
||||
private void createOrder3(Customer customer) {
|
||||
|
||||
Product product1 = Ebean.getReference(Product.class, 1);
|
||||
Product product3 = Ebean.getReference(Product.class, 3);
|
||||
|
||||
Order order = new Order();
|
||||
order.setStatus(Status.COMPLETE);
|
||||
order.setCustomer(customer);
|
||||
|
||||
List<OrderDetail> details = new ArrayList<>();
|
||||
details.add(new OrderDetail(product1, 3, 10.50));
|
||||
details.add(new OrderDetail(product3, 40, 2.10));
|
||||
details.add(new OrderDetail(product1, 5, 10.00));
|
||||
order.setDetails(details);
|
||||
|
||||
order.addShipment(new OrderShipment());
|
||||
|
||||
Ebean.save(order);
|
||||
}
|
||||
|
||||
private void createOrder4(Customer customer) {
|
||||
|
||||
Order order = new Order();
|
||||
order.setCustomer(customer);
|
||||
|
||||
order.addShipment(new OrderShipment());
|
||||
|
||||
Ebean.save(order);
|
||||
}
|
||||
|
||||
private void createOrder5(Customer customer) {
|
||||
|
||||
Order order = new Order();
|
||||
order.setCustomer(customer);
|
||||
order.addShipment(new OrderShipment());
|
||||
|
||||
Ebean.save(order);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Cache
|
||||
@Entity
|
||||
public class Section extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public enum Type {
|
||||
GENERAL,
|
||||
NOTE
|
||||
}
|
||||
|
||||
@ManyToOne
|
||||
Article article;
|
||||
|
||||
Type type = Type.GENERAL;
|
||||
|
||||
@Lob
|
||||
String content;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
List<SubSection> subSections;
|
||||
|
||||
public Section() {
|
||||
}
|
||||
|
||||
public Section(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Article getArticle() {
|
||||
return article;
|
||||
}
|
||||
|
||||
public void setArticle(Article article) {
|
||||
this.article = article;
|
||||
}
|
||||
|
||||
public List<SubSection> getSubSections() {
|
||||
return subSections;
|
||||
}
|
||||
|
||||
public void setSubSections(List<SubSection> subSections) {
|
||||
this.subSections = subSections;
|
||||
}
|
||||
|
||||
public void addSubSection(SubSection s) {
|
||||
if (subSections == null) {
|
||||
subSections = new ArrayList<>();
|
||||
}
|
||||
subSections.add(s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
public enum SomeEnum {
|
||||
|
||||
ALPHA("Some nice Alpha"),
|
||||
BETA("Some nice Beta");
|
||||
|
||||
String description;
|
||||
|
||||
SomeEnum(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class SomeEnumBean {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@Enumerated
|
||||
SomeEnum someEnum;
|
||||
|
||||
String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public SomeEnum getSomeEnum() {
|
||||
return someEnum;
|
||||
}
|
||||
|
||||
public void setSomeEnum(SomeEnum someEnum) {
|
||||
this.someEnum = someEnum;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
public class SomeObject {
|
||||
|
||||
String nonScalar;
|
||||
Integer value;
|
||||
|
||||
public String getNonScalar() {
|
||||
return nonScalar;
|
||||
}
|
||||
|
||||
public void setNonScalar(String nonScalar) {
|
||||
this.nonScalar = nonScalar;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.Cache;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Cache
|
||||
@Entity
|
||||
public class SubSection extends BasicDomain {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ManyToOne
|
||||
private Section section;
|
||||
|
||||
private String title;
|
||||
|
||||
public SubSection() {
|
||||
}
|
||||
|
||||
public SubSection(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
|
||||
@Entity
|
||||
public class TBytesOnly {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
@Lob
|
||||
@Basic(fetch = FetchType.EAGER)
|
||||
byte[] content;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public byte[] getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(byte[] content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Inheritance;
|
||||
|
||||
@Entity
|
||||
@Inheritance
|
||||
@DiscriminatorValue("2")
|
||||
public class TIntChild extends TIntRoot {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
String childProperty;
|
||||
|
||||
public String getChildProperty() {
|
||||
return childProperty;
|
||||
}
|
||||
|
||||
public void setChildProperty(String childProperty) {
|
||||
this.childProperty = childProperty;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import javax.persistence.DiscriminatorColumn;
|
||||
import javax.persistence.DiscriminatorType;
|
||||
import javax.persistence.DiscriminatorValue;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Inheritance;
|
||||
|
||||
@Entity
|
||||
@Inheritance
|
||||
@DiscriminatorColumn(name = "my_type", length = 3, discriminatorType = DiscriminatorType.INTEGER)
|
||||
@DiscriminatorValue("1")
|
||||
public class TIntRoot {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import org.joda.time.LocalTime;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class TJodaEntity {
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
LocalTime localTime;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public LocalTime getLocalTime() {
|
||||
return localTime;
|
||||
}
|
||||
|
||||
public void setLocalTime(LocalTime localTime) {
|
||||
this.localTime = localTime;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package org.tests.model.basic;
|
||||
|
||||
import io.ebean.annotation.UpdateMode;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "t_mapsuper1")
|
||||
@UpdateMode(updateChangesOnly = true)
|
||||
public class TMapSuperEntity extends TMappedSuper2 {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
Integer id;
|
||||
|
||||
String name;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user