Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Shared Cache not working when using eclipselink with Spring
Shared Cache not working when using eclipselink with Spring [message #639281] Mon, 15 November 2010 21:48 Go to next message
Missing name Missing name is currently offline Missing name Missing name
Messages: 3
Registered: November 2010
Junior Member
According to this page http://wiki.eclipse.org/EclipseLink/Examples/JPA/JPASpring#C ommon_Issues, and a few tests I ran, you cannot Shared Cache when using EclipseLink with Spring. Is this true?
Are there any workarounds?

# Spring forces the database transaction to begin with the JPA transaction, this will cause objects read in a transaction to not be cached in EclipseLink's shared cache.

[Updated on: Mon, 15 November 2010 22:24]

Report message to a moderator

Re: Shared Cache not working when using eclipselink with Spring [message #639973 is a reply to message #639281] Thu, 18 November 2010 15:22 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

This is true.

There is a setLazyDatabaseTransaction() method on the Spring EclipseLinkJpaDialect. You can set this to false to avoid this issue, you should be able to configure this in your Spring config. Or you could create you own EclipseLink dialect and remove the beginTransaction() method.

I logged a bug for this in Spring here,
https://jira.springframework.org/browse/SPR-7753

There is also an EclipseLink bug that you can vote for,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=288383


James : Wiki : Book : Blog : Twitter
Re: Shared Cache not working when using eclipselink with Spring [message #642340 is a reply to message #639973] Tue, 30 November 2010 20:42 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing name
Messages: 3
Registered: November 2010
Junior Member
I tried setting the lazyDatabaseTransaction to true and adding setting eclipselink.jdbc.exclusive-connection.mode to Always but neither had any effect. Objects are still not getting cached! Is there anything else I can try? How can verify if Eclipselink is being forced to use a transactional connection?
Re: Shared Cache not working when using eclipselink with Spring [message #642791 is a reply to message #639281] Thu, 02 December 2010 17:02 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Setting the lazyDatabaseTransaction to true should work. Otherwise yo may need to customize your dialect in Spring.

You can check if the uow is isolated to the transaction by getting the unit of work from the EntityManager and checking,
wasTransactionBegunPrematurely()

Technically you could also switch this calling
setWasTransactionBegunPrematurely(false)
but probably better to fix it in Spring.


James : Wiki : Book : Blog : Twitter
Previous Topic:Multiple TableGenerators per Entity
Next Topic:No Cache Synchronization after em.clear?
Goto Forum:
  


Current Time: Wed Oct 01 16:31:13 GMT 2014

Powered by FUDForum. Page generated in 0.03573 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software