mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Testcase for ebean with circular dependences
1. While the javax.persistance api discourages the use of bidirectional cascades, it does not prohibit them. They're very useful and natural if you think of the database as a graph instead of a tree. test case 1 (testCircularCascade) tests this. 2. Second test case fetches the child, but saves the parent. If used like that, the child will not have it's changes saved.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package org.tests.update.objects;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
|
||||
@Entity
|
||||
@Table(name = "e_save_test_c")
|
||||
public class Parent {
|
||||
@Id
|
||||
private Long id;
|
||||
@Version
|
||||
private long version = 0L;
|
||||
@OneToOne(cascade = CascadeType.ALL)
|
||||
private Child child;
|
||||
|
||||
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 Child getChild() {
|
||||
return child;
|
||||
}
|
||||
|
||||
public void setChild(Child child) {
|
||||
this.child = child;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user