Sandhya:
After more investigation, I've determined that the issue is
transactional. See below.
EntityManager em = EntityManagerHelper.getEntityManager();
em.getTransaction().begin();
Category cat = em.find(Category.class, "AB_STATUS");
int countCatCatqs = cat.getLinkCatCatqs().size();
Category cat2 = em.find(Category.class, "DEFAULT");
int countCatCatqs2 = cat2.getLinkCatCatqs().size();
em.getTransaction().commit();
countCatCatqs contains the correct value (gt zero) but countCatCatqs2 is
always zero. The difference is that the "AB_STATUS" Category exists in
the DB prior to the test case running where the "DEFAULT" Category is
added during the setup method of the test case.
Again, simply disabling the dataCache fixes the issue. I've checked and
rechecked my transactional logic. The setup method uses the same code as
above to wrap the persist calls (em.persist) in a transaction.
Any ideas?
Jeff
Jeff W. Boring
Lockheed Martin
Orlando, Fl 32825
-----Original Message-----
From: Boring, Jeff W (N-Viper)
Sent: Wednesday, December 10, 2008 9:49 AM
To: users@openjpa.apache.org; turagasandy@yahoo.com
Subject: RE: Strange issue with using DataCache
Sandhya:
Thanks for the help. Below is more detail as to what is occurring. Note
that I've had to modify the code & logs because this is a US defense
project and we can't let out production code.
When the cache is disabled:
<property name="openjpa.DataCache" value="false(CacheSize=100000,
SoftReferenceSize=0)" />
<property name="openjpa.RemoteCommitProvider" value="sjvm"/>
This query returns a count of 3:
link = dao.findById(linkToCou.getClass(),linkToCou.getSid());
int count = linkToCou.getLinkJmsqOutputs().size();
JPA Logging:
30665 DmJpaCIDI TRACE [main] openjpa.jdbc.SQL - <t 15431769, conn
9336124> executing prepstmnt 16335556
SELECT ....
FROM t0, t1, t2, t3, t4
WHERE ......
[params=(long) 553]
30712 DmJpaCIDI TRACE [main] openjpa.jdbc.SQL - <t 15431769, conn
9336124> [31 ms] spent
30728 DmJpaCIDI TRACE [main] openjpa.jdbc.SQL - <t 15431769, conn
9336124> executing prepstmnt 15703296
SELECT *
FROM t0, t1, t2 t3, t4, t5, t6
WHERE ......
[params=(long) 597]
30743 DmJpaCIDI TRACE [main] openjpa.jdbc.SQL - <t 15431769, conn
9336124> [15 ms] spent
30790 DmJpaCIDI TRACE [main] openjpa.jdbc.SQL - <t 15431769, conn
9336124> executing prepstmnt 25615763
SELECT ...
FROM t0, t1, t2, t3, t4, t5, t6
WHERE ...
[params=(long) 598]
30806 DmJpaCIDI TRACE [main] openjpa.jdbc.SQL - <t 15431769, conn
9336124> [16 ms] spent
30837 DmJpaCIDI TRACE [main] openjpa.jdbc.SQL - <t 15431769, conn
9336124> executing prepstmnt 2968702
SELECT ...
FROM t0, t1, t2, t3, t4, t5, t6
WHERE ......
[params=(long) 599]
30853 DmJpaCIDI TRACE [main] openjpa.jdbc.SQL - <t 15431769, conn
9336124> [16 ms] spent
When the cache is enabled:
<property name="openjpa.DataCache" value="true(CacheSize=100000,
SoftReferenceSize=0)" />
<property name="openjpa.RemoteCommitProvider" value="sjvm"/>
This query returns a count of 0:
link = dao.findById(linkToCou.getClass(),linkToCou.getSid());
int count = linkToCou.getLinkJmsqOutputs().size();
JPA Logging:
35475 DmJpaCIDI TRACE [main] openjpa.DataCache - Cache hit while
looking up key "com.lmco.jpa.entity.Link-554".
39051 DmJpaCIDI TRACE [main] openjpa.DataCache - Cache hit while
looking up key "com.lmco.jpa.entity.Link -554".
39051 DmJpaCIDI TRACE [main] openjpa.DataCache - Cache hit while
looking up key "com.lmco.jpa.entity.Link -554".
Does this help or do you need more?
Jeff
Jeff W. Boring
Lockheed Martin
12506 Lake Underhill Road
Orlando, Fl 32825
-----Original Message-----
From: Sandhya Kishore [mailto:turagasandy@yahoo.com]
Sent: Tuesday, December 09, 2008 7:37 PM
To: users@openjpa.apache.org
Subject: Re: Strange issue with using DataCache
Hi Jeff,
One more thing is if you want your entities to be stored in the
datacache @DataCache annotation should be specified on those entities.
Otherwise even though you specify the cache size to so much and enable
the datacache, these entities might not be stored in the cache.
Also I could not reproduce the problem. I have set the same properties
as specified and tries to find some entities and it seemed work fine for
me. Can you send your testcase along with your entities and
configuration that you have specified?
Also what is it mean when you say "entity set's always have size of
zero"
Thanks
Sandhya
--- On Tue, 12/9/08, Boring, Jeff W (N-Viper) <jeff.w.boring@lmco.com>
wrote:
From: Boring, Jeff W (N-Viper) <jeff.w.boring@lmco.com>
Subject: Strange issue with using DataCache
To: users@openjpa.apache.org
Date: Tuesday, December 9, 2008, 3:29 PM
Using OpenJpa v1.0.0
When the following
properties exist in the persistence.xml file, entity
set's always have size of zero and test cases fail.
<property name="openjpa.DataCache"
value="true(CacheSize=5000000, SoftReferenceSize=0)" />
<property name="openjpa.RemoteCommitProvider"
value="sjvm"/>
Changing the DataCache property value to false corrects the issue; all
test pass.
I've used the DataCache before in a sample/simple app but now I am
trying to apply it to a production app. I implemented the DataCache fine
but noticed that test cases were failing. I then just turned it off and
everything worked again, but, of course, no cache. I then took out all
new code (except 2 properties above) including the @DataCache
annotations and reran the tests and it still fails when dataCache is set
to true. Passes when set to false.
I then debugged, stepping thru a test and discovered than the sets are
all empty.
Sorry
for the long question. Thanks for any help you can give.
Jeff
Jeff W. Boring
Lockheed Martin
Orlando, Fl 32825
|