mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Add Period support via CompoundTypePeriod, rename server/reflect to server/properties
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package com.avaje.tests.model.types;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Version;
|
||||
import java.time.*;
|
||||
|
||||
@Entity
|
||||
public class SomePeriodBean {
|
||||
|
||||
@Id
|
||||
Long id;
|
||||
|
||||
@Version
|
||||
Long version;
|
||||
|
||||
Period period;
|
||||
|
||||
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 Period getPeriod() {
|
||||
return period;
|
||||
}
|
||||
|
||||
public void setPeriod(Period period) {
|
||||
this.period = period;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.avaje.tests.types;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.tests.model.types.SomePeriodBean;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.time.Period;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class TestPeriodType extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testInsert() {
|
||||
|
||||
SomePeriodBean bean = new SomePeriodBean();
|
||||
bean.setPeriod(Period.of(3, 4, 5));
|
||||
Ebean.save(bean);
|
||||
|
||||
SomePeriodBean bean1 = Ebean.find(SomePeriodBean.class, bean.getId());
|
||||
assertEquals(bean.getPeriod(), bean1.getPeriod());
|
||||
|
||||
// insert fetch null value
|
||||
SomePeriodBean bean2 = new SomePeriodBean();
|
||||
Ebean.save(bean2);
|
||||
|
||||
SomePeriodBean bean3 = Ebean.find(SomePeriodBean.class, bean2.getId());
|
||||
assertNull(bean3.getPeriod());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user