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,34 @@
|
||||
package org.tests.model.zero;
|
||||
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class TestWithZero extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testInsertUpdate() {
|
||||
|
||||
|
||||
WithZero withZero = new WithZero();
|
||||
assertEquals(0, withZero.getId());
|
||||
assertEquals(0, withZero.getVersion());
|
||||
assertNull(withZero.getName());
|
||||
|
||||
WithZeroParent parent = new WithZeroParent();
|
||||
parent.getChildren().add(withZero);
|
||||
|
||||
Ebean.save(parent);
|
||||
|
||||
parent.getChildren().add(new WithZero());
|
||||
|
||||
//withZero.setName("Foo");
|
||||
Ebean.save(parent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package org.tests.model.zero;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
public class WithZero {
|
||||
|
||||
@Id
|
||||
long id = 0;
|
||||
|
||||
String name;
|
||||
|
||||
@ManyToOne
|
||||
WithZeroParent parent;
|
||||
|
||||
@Column(columnDefinition = "varchar(2) default 'en' not null")
|
||||
String lang = "en";
|
||||
|
||||
@Version
|
||||
long version = 0;
|
||||
|
||||
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 getLang() {
|
||||
return lang;
|
||||
}
|
||||
|
||||
public void setLang(String lang) {
|
||||
this.lang = lang;
|
||||
}
|
||||
|
||||
public WithZeroParent getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public void setParent(WithZeroParent parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.tests.model.zero;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "parent")
|
||||
public class WithZeroParent {
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
private int id;
|
||||
|
||||
String name;
|
||||
|
||||
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
|
||||
private List<WithZero> children;
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<WithZero> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(final List<WithZero> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user