mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Removed onPersistTrigger
This commit is contained in:
@@ -109,9 +109,4 @@ public interface EntityBean extends Serializable {
|
||||
throw new NotEnhancedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalcs the bean. This is invoked by PersistRequestBean.
|
||||
*/
|
||||
default void _ebean_onPersistTrigger(String profileEventId) {};
|
||||
|
||||
}
|
||||
|
||||
@@ -148,12 +148,8 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
|
||||
super(server, t, persistExecute);
|
||||
this.entityBean = (EntityBean) bean;
|
||||
this.intercept = entityBean._ebean_getIntercept();
|
||||
this.beanDescriptor = mgr.getBeanDescriptor();
|
||||
boolean isReference = beanDescriptor.isReference(intercept);
|
||||
if(!isReference) {
|
||||
this.entityBean._ebean_onPersistTrigger(type.profileEventId);
|
||||
}
|
||||
this.beanManager = mgr;
|
||||
this.beanDescriptor = mgr.getBeanDescriptor();
|
||||
this.beanPersistListener = beanDescriptor.persistListener();
|
||||
this.bean = bean;
|
||||
this.parentBean = parentBean;
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package org.tests.o2o;
|
||||
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class OtoLevelALazy {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
@OneToOne(mappedBy = "a", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private OtoLevelBLazy b;
|
||||
|
||||
public OtoLevelALazy(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public OtoLevelBLazy getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void setB(OtoLevelBLazy b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package org.tests.o2o;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
@Entity
|
||||
public class OtoLevelBLazy {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
@ManyToMany()
|
||||
private List<OtoLevelC> c;
|
||||
|
||||
@OneToOne()
|
||||
private OtoLevelALazy a;
|
||||
|
||||
@Lob
|
||||
private String blb;
|
||||
|
||||
public OtoLevelBLazy(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public OtoLevelALazy getA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public void setA(OtoLevelALazy a) {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<OtoLevelC> getC() {
|
||||
return c;
|
||||
}
|
||||
|
||||
public final void _ebean_onPersistTrigger(String trt) {
|
||||
recalc();
|
||||
}
|
||||
|
||||
protected void recalc() {
|
||||
this.getBlb();
|
||||
}
|
||||
|
||||
public String getBlb() {
|
||||
return blb;
|
||||
}
|
||||
|
||||
public void setBlb(String blb) {
|
||||
this.blb = blb;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
package org.tests.o2o;
|
||||
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import io.ebean.DB;
|
||||
import io.ebean.test.LoggedSql;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import io.ebean.DB;
|
||||
import io.ebean.test.LoggedSql;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestOneToOneSaveWithoutChanges {
|
||||
|
||||
@@ -34,19 +33,4 @@ public class TestOneToOneSaveWithoutChanges {
|
||||
List<String> sql = LoggedSql.stop();
|
||||
assertThat(sql).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSave2LevelsLazyPersistTrigger() {
|
||||
OtoLevelALazy a = new OtoLevelALazy("A");
|
||||
OtoLevelBLazy b = new OtoLevelBLazy("B");
|
||||
b.setA(a);
|
||||
DB.save(a);
|
||||
DB.save(b);
|
||||
|
||||
OtoLevelALazy dbA = DB.find(OtoLevelALazy.class).select("*").where().idEq(1).findList().get(0);
|
||||
LoggedSql.start();
|
||||
DB.save(dbA);
|
||||
List<String> sql = LoggedSql.stop();
|
||||
assertThat(sql).hasSize(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user