mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
For experimental "transparent persistence" - Delete removes from PC early
When delete bean executed with transparent persistence, this marks the bean as removed from the persistence context early. This avoids a "dirty" deleted bean from being seen as a "dirty" bean in the persistence context at flush() time.
This commit is contained in:
@@ -17,6 +17,29 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TestTransparentPersist extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void delete_expect_beanRemovedFromPersistenceContext() {
|
||||
|
||||
EBasicVer b0 = new EBasicVer("simpleDelete");
|
||||
DB.save(b0);
|
||||
|
||||
try (Transaction transaction = DB.beginTransaction()) {
|
||||
transaction.setTransparentPersistence(true); // EXPERIMENTAL feature
|
||||
|
||||
EBasicVer found = DB.find(EBasicVer.class, b0.getId());
|
||||
// make it dirty
|
||||
found.setName("make it dirty");
|
||||
|
||||
// delete it, should remove it from the "live" part of persistence context
|
||||
// with the expectation that no update is executed (no dirty in PC update)
|
||||
DB.delete(found);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
EBasicVer after = DB.find(EBasicVer.class, b0.getId());
|
||||
assertThat(after).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleInsertUpdateDelete_experimental() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user