mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1251 - Delete cascade with 11+ and Postgres throws exception
Failing test
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package org.tests.model.onetoone;
|
||||
|
||||
import org.tests.model.BaseModel;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class OtoThMany extends BaseModel {
|
||||
|
||||
String many;
|
||||
|
||||
@OneToOne(mappedBy = "many", cascade = CascadeType.ALL)
|
||||
OtoThOne one;
|
||||
|
||||
public String getMany() {
|
||||
return many;
|
||||
}
|
||||
|
||||
public void setMany(String many) {
|
||||
this.many = many;
|
||||
}
|
||||
|
||||
public OtoThOne getOne() {
|
||||
return one;
|
||||
}
|
||||
|
||||
public void setOne(OtoThOne one) {
|
||||
this.one = one;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.tests.model.onetoone;
|
||||
|
||||
import org.tests.model.BaseModel;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class OtoThOne extends BaseModel {
|
||||
|
||||
boolean one;
|
||||
|
||||
@OneToOne
|
||||
OtoThMany many;
|
||||
|
||||
public boolean isOne() {
|
||||
return one;
|
||||
}
|
||||
|
||||
public void setOne(boolean one) {
|
||||
this.one = one;
|
||||
}
|
||||
|
||||
public OtoThMany getMany() {
|
||||
return many;
|
||||
}
|
||||
|
||||
public void setMany(OtoThMany many) {
|
||||
this.many = many;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.tests.model.onetoone;
|
||||
|
||||
import org.tests.model.BaseModel;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class OtoThTop extends BaseModel {
|
||||
|
||||
String top;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
List<OtoThMany> manies;
|
||||
|
||||
public String getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public void setTop(String top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
public List<OtoThMany> getManies() {
|
||||
return manies;
|
||||
}
|
||||
|
||||
public void setManies(List<OtoThMany> manies) {
|
||||
this.manies = manies;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package org.tests.model.onetoone;
|
||||
|
||||
import io.ebean.Ebean;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestOneToOneManyDelete {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
OtoThTop top = new OtoThTop();
|
||||
top.setTop("top");
|
||||
for (int i = 0; i < 4; i++) {
|
||||
|
||||
OtoThMany many = new OtoThMany();
|
||||
many.setMany("many "+i);
|
||||
|
||||
OtoThOne one = new OtoThOne();
|
||||
one.setOne(true);
|
||||
one.setMany(many);
|
||||
|
||||
many.setOne(one);
|
||||
|
||||
top.getManies().add(many);
|
||||
}
|
||||
|
||||
Ebean.save(top);
|
||||
|
||||
Ebean.delete(top);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user