mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-11 22:32:22 +00:00
Test for #105 - did not reproduce - Ebean is trying to delete new
objects added to the list of an entity and then removed without being persisted before
This commit is contained in:
1 parent
90b23c4985
commit
f773d74597
2 files changed
+35
-2
No files matched your search
@@ -0,0 +1,34 @@
|
||||
package com.avaje.tests.cascade;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.tests.model.basic.TSDetail;
|
||||
import com.avaje.tests.model.basic.TSMaster;
|
||||
|
||||
public class TestPrivateOwnedAddRemoveOrphan extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test(){
|
||||
|
||||
// setup
|
||||
TSMaster master0 = new TSMaster();
|
||||
Ebean.save(master0);
|
||||
|
||||
// act
|
||||
TSMaster master1 = Ebean.find(master0.getClass(), master0.getId());
|
||||
|
||||
TSDetail tsDetail = new TSDetail();
|
||||
// Add then remove a bean that was never saved (to the DB)
|
||||
master1.getDetails().add(tsDetail);
|
||||
master1.getDetails().remove(tsDetail);
|
||||
|
||||
Ebean.save(master1);
|
||||
|
||||
TSMaster master2 = Ebean.find(master1.getClass(), master1.getId());
|
||||
|
||||
Assert.assertTrue(master2.getDetails().isEmpty());
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,7 @@ package com.avaje.tests.cascade;
|
||||
|
||||
import javax.persistence.OptimisticLockException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
|
||||
Reference in new issue
Block a user