[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[eclipselink-users] If JPA Cache is enabled it's possible to get more Entitys as stored in the underlying database
|
Strange behavior: If JPA Cache is enabled it's possible to get more Entitys
as stored in the underlying database.
I made an example here: https://github.com/helmut-at-work/test-jpacache
<https://github.com/helmut-at-work/test-jpacache>
Test:
@RunWith(Arquillian.class)
public class ManagerArquillianTest {
@EJB
Manager manager;
....
@Test
public void testOneToManyWithDoubleChildObjects() throws Exception {
System.out.println("Test a simple OneToMany with 1 parent and 3
childs, where 2 childs are the same object.");
ParentNode pdetached = new ParentNode();
ChildNode c1 = new ChildNode();
c1.setParentNode(pdetached);
pdetached.getChilds().add(c1);
ChildNode c2 = new ChildNode();
c2.setParentNode(pdetached);
pdetached.getChilds().add(c2);
//add the same object twice (not sure what happen)
pdetached.getChilds().add(c2);
//What is to be expected? 3 or 2 Rows in database table childnode?
manager.saveParentNode(pdetached);
//Let's see what is in the database with simple SQL
int count = countChildNodes();
//We get 2 rows in childnode!
assertEquals(2, count);
//Ok let's read with jpa and cache active
ParentNode pread = manager.getParentNode();
// I think we should get 2 childnotes now, right?
assertEquals(2, pread.getChilds().size());
//When we disable the cache in persistence.xml this test will pass.
...
Have someone see this before, or see the error I possible made?
--
View this message in context: http://eclipse.1072660.n5.nabble.com/If-JPA-Cache-is-enabled-it-s-possible-to-get-more-Entitys-as-stored-in-the-underlying-database-tp158489.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.