#348 - ENH: Add @WhenCreated and @WhenModified ... as alias to existing @CreatedTimestamp and @UpdatedTimstamp

This commit is contained in:
Robin Bygrave committed 2015-07-24 10:50:35 +12:00
1 parent 3a547bf487
commit 1085a8d608
10 files changed
+108 -22

No files matched your search

@@ -18,6 +18,8 @@ public class TestGeneratedProperties extends BaseTestCase {
assertNotNull(bean.getId());
assertNotNull(bean.getVersion());
assertNotNull(bean.getWhenCreated());
assertNotNull(bean.getWhenModified());
assertNotNull(bean.getTsCreated());
assertNotNull(bean.getTsUpdated());
assertNotNull(bean.getLdtCreated());
@@ -7,8 +7,8 @@ import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import com.avaje.ebean.Model;
import com.avaje.ebean.annotation.CreatedTimestamp;
import com.avaje.ebean.annotation.UpdatedTimestamp;
import com.avaje.ebean.annotation.WhenCreated;
import com.avaje.ebean.annotation.WhenModified;
@MappedSuperclass
public class BaseModel extends Model {
@@ -19,11 +19,11 @@ public class BaseModel extends Model {
@Version
Long version;
@CreatedTimestamp
@WhenCreated
Timestamp whenCreated;
@UpdatedTimestamp
Timestamp whenUpdated;
@WhenModified
Timestamp whenModified;
public Long getId() {
return id;
@@ -49,12 +49,12 @@ public class BaseModel extends Model {
this.whenCreated = whenCreated;
}
public Timestamp getWhenUpdated() {
return whenUpdated;
public Timestamp getWhenModified() {
return whenModified;
}
public void setWhenUpdated(Timestamp whenUpdated) {
this.whenUpdated = whenUpdated;
public void setWhenModified(Timestamp whenModified) {
this.whenModified = whenModified;
}
}
@@ -2,6 +2,8 @@ package com.avaje.tests.model;
import com.avaje.ebean.annotation.CreatedTimestamp;
import com.avaje.ebean.annotation.UpdatedTimestamp;
import com.avaje.ebean.annotation.WhenCreated;
import com.avaje.ebean.annotation.WhenModified;
import javax.persistence.Entity;
import javax.persistence.Id;
@@ -22,6 +24,12 @@ public class EGenProps {
@Version
Long version;
@WhenCreated
Timestamp whenCreated;
@WhenModified
Timestamp whenModified;
@CreatedTimestamp
Timestamp tsCreated;
@@ -76,6 +84,22 @@ public class EGenProps {
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;
}
@@ -7,8 +7,8 @@ import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import com.avaje.ebean.annotation.CreatedTimestamp;
import com.avaje.ebean.annotation.UpdatedTimestamp;
import com.avaje.ebean.annotation.WhenCreated;
import com.avaje.ebean.annotation.WhenModified;
@MappedSuperclass
public class BasicDomain implements Serializable {
@@ -18,10 +18,10 @@ public class BasicDomain implements Serializable {
@Id
Integer id;
@CreatedTimestamp
@WhenCreated
Timestamp cretime;
@UpdatedTimestamp
@WhenModified
Timestamp updtime;
@Version
@@ -22,8 +22,8 @@ import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlType;
import com.avaje.ebean.annotation.CreatedTimestamp;
import com.avaje.ebean.annotation.Formula;
import com.avaje.ebean.annotation.WhenCreated;
import com.avaje.ebean.annotation.Where;
/**
@@ -90,7 +90,7 @@ public class Order implements Serializable {
@Column(name = "name", table = "o_customer")
String customerName;
@CreatedTimestamp
@WhenCreated
Timestamp cretime;
@Version
@@ -69,7 +69,7 @@ public class TestOneToOneOptionalRelationship extends BaseTestCase {
Assert.assertTrue(sql.contains(" from oto_account t0 left outer join oto_user t1 on t1.account_id = t0.id where t0.id = ?"));
String lazyLoadSql = loggedSql.get(1);
Assert.assertTrue(lazyLoadSql.contains("select t0.id c0, t0.name c1, t0.version c2, t0.when_created c3, t0.when_updated c4, t0.account_id c5 from oto_user t0 where t0.id = ?"));
Assert.assertTrue(lazyLoadSql.contains("select t0.id c0, t0.name c1, t0.version c2, t0.when_created c3, t0.when_modified c4, t0.account_id c5 from oto_user t0 where t0.id = ?"));
}