mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Test case for #75 - Persistence Context Cache not cleared when updating an entity in a running transaction. Actually the test case does not fail.
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
||||
package com.avaje.tests.persistencecontext;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
|
||||
import com.avaje.ebean.BaseTestCase;
|
||||
import com.avaje.ebean.Ebean;
|
||||
import com.avaje.ebean.EbeanServer;
|
||||
import com.avaje.tests.model.basic.EBasic;
|
||||
|
||||
public class TestPersistenceContextOnUpdateDuringTxn extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
EbeanServer server = Ebean.getServer(null);
|
||||
|
||||
server.beginTransaction();
|
||||
try {
|
||||
|
||||
EBasic bean1 = new EBasic();
|
||||
bean1.setName("hello");
|
||||
|
||||
server.save(bean1);
|
||||
|
||||
EBasic updatedEntity = new EBasic();
|
||||
updatedEntity.setId(bean1.getId());
|
||||
updatedEntity.setName("hello-changed");
|
||||
|
||||
server.update(updatedEntity);
|
||||
|
||||
// actually the bean is not in the persistence context so ... the assert is fine
|
||||
EBasic loadedEntity = server.find(EBasic.class,bean1.getId());
|
||||
|
||||
assertThat(loadedEntity.getName(), is("hello-changed"));
|
||||
|
||||
} finally {
|
||||
server.endTransaction();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user