Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] find after persist is not finding persisted value

I am having trouble with calling a find after a persist in a JTA transaction
unless I add an explicit flush() command. Is this because of some caching
configuration?

This code results in a null foundValue entity:
em.persist(value);
String id = value.getId();
Value foundValue = em.find(Value.class, id);

[EL Finer]: 2009.04.14
11:09:25.375--ServerSession(25994851)--Thread(Thread[main,5,main])--client
acquired
[EL Finer]: 2009.04.14
11:09:25.375--UnitOfWork(28410421)--Thread(Thread[main,5,main])--TX binding
to tx mgr, status=STATUS_ACTIVE
[EL Finest]: 2009.04.14
11:09:25.375--UnitOfWork(28410421)--Thread(Thread[main,5,main])--PERSIST
operation called on:
org.kuali.student.common_test_tester.support.Value@1a18ee2.
[EL Finest]: 2009.04.14
11:09:25.453--UnitOfWork(28410421)--Thread(Thread[main,5,main])--Execute
query ReadObjectQuery(org.kuali.student.common_test_tester.support.Value)
[EL Finest]: 2009.04.14
11:09:25.484--ServerSession(25994851)--Thread(Thread[main,5,main])--reconnecting
to external connection pool
[EL Fine]: 2009.04.14
11:09:25.484--ServerSession(25994851)--Connection(27969397)--Thread(Thread[main,5,main])--SELECT
ID, VALUE, CREATEDATE FROM VALUE WHERE (ID = ?)
	bind => [6793d86e-eb7e-4f0c-a4be-0606a7e634c4]
[EL Finer]: 2009.04.14
11:09:25.750--UnitOfWork(28410421)--Thread(Thread[main,5,main])--TX
afterCompletion callback, status=ROLLEDBACK
[EL Finer]: 2009.04.14
11:09:25.750--UnitOfWork(28410421)--Thread(Thread[main,5,main])--release
unit of work
[EL Finer]: 2009.04.14
11:09:25.750--ClientSession(10334434)--Thread(Thread[main,5,main])--client
released

If I add a flush between the calls it works correctly:
em.persist(value);
em.flush();
String id = value.getId();
Value foundValue = em.find(Value.class, id);

[EL Finer]: 2009.04.14
11:17:06.546--ServerSession(22844058)--Thread(Thread[main,5,main])--client
acquired
[EL Finer]: 2009.04.14
11:17:06.546--UnitOfWork(11538114)--Thread(Thread[main,5,main])--TX binding
to tx mgr, status=STATUS_ACTIVE
[EL Finest]: 2009.04.14
11:17:06.546--UnitOfWork(11538114)--Thread(Thread[main,5,main])--PERSIST
operation called on:
org.kuali.student.common_test_tester.support.Value@87cd5c.
[EL Finer]: 2009.04.14
11:17:06.625--ClientSession(3470405)--Thread(Thread[main,5,main])--TX
beginTransaction, status=STATUS_ACTIVE
[EL Finest]: 2009.04.14
11:17:06.640--UnitOfWork(11538114)--Thread(Thread[main,5,main])--Execute
query
InsertObjectQuery(org.kuali.student.common_test_tester.support.Value@87cd5c)
[EL Finest]: 2009.04.14
11:17:06.640--ClientSession(3470405)--Thread(Thread[main,5,main])--reconnecting
to external connection pool
[EL Fine]: 2009.04.14
11:17:06.640--ClientSession(3470405)--Connection(15805298)--Thread(Thread[main,5,main])--INSERT
INTO VALUE (ID, VALUE, CREATEDATE) VALUES (?, ?, ?)
	bind => [c6882772-c7c6-46d4-bba4-eb38e89d59c6, Cheerios, null]
[EL Finest]: 2009.04.14
11:17:06.765--UnitOfWork(11538114)--Thread(Thread[main,5,main])--Execute
query ReadObjectQuery(org.kuali.student.common_test_tester.support.Value)
[EL Finer]: 2009.04.14
11:17:06.937--UnitOfWork(11538114)--Thread(Thread[main,5,main])--TX
afterCompletion callback, status=ROLLEDBACK
[EL Finer]: 2009.04.14
11:17:06.937--UnitOfWork(11538114)--Thread(Thread[main,5,main])--release
unit of work
[EL Finer]: 2009.04.14
11:17:06.937--ClientSession(3470405)--Thread(Thread[main,5,main])--client
released
-- 
View this message in context: http://www.nabble.com/find-after-persist-is-not-finding-persisted-value-tp23041581p23041581.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top