Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Re: sync error with eclipselink
Re: sync error with eclipselink [message #729637] Mon, 26 September 2011 16:53 Go to next message
Wolfgang is currently offline WolfgangFriend
Messages: 12
Registered: July 2009
Junior Member
not sure what part of your question is still open - eclipselink uses caching, you best look this up in the doco.
If you change the object returned by eclipselink you make the cached object dirty.
So you have at least two options - either work on a copy (clone) of the cached object and merge this back when the change is committed or work on the original and refresh if cancelled

hope this helps
Re: sync error with eclipselink [message #729641 is a reply to message #729637] Mon, 26 September 2011 17:09 Go to previous messageGo to next message
Luiz E. is currently offline Luiz E.Friend
Messages: 100
Registered: September 2010
Senior Member
seems like something weird happened to my thread.
well, after a little research, i got the way i'm instantiating my entitymanager is causing this
i'm using a local thread, and do like this
public static EntityManager createEntityManager() {
		EntityManager entityManager = ENTITY_MANAGER_CACHE.get();
		if (entityManager == null) {
			ENTITY_MANAGER_CACHE.set(entityManager = emf.createEntityManager());
		return entityManager;

this way, i have only one entityManger per thread, and i think this is causing this strange behavior
any ideas?
Re: sync error with eclipselink [message #730040 is a reply to message #729641] Tue, 27 September 2011 14:30 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1382
Registered: July 2009
Senior Member
You are sharing an EntityManager which is essentially a transactional context - you are likely in an extended environment. The cache settings you have been using are for the shared cache, which is used between EntityManager instances, and does not affect individual EntityManagers which are required to keep managed entities in the cache until they are cleared.

As Wolfgang mentioned, you will either need to detach entities and merge them back in when you want to persist changes, or refresh the entities when needed. To detach the entities, either close the EntityManager and obtain a new one, or call clear on it. Your shared cache settings will then come into play when reading from an empty EntityManager.

Previous Topic:EclipseLink + RCP + OSGI Service: No Persistence provider for EntityManager
Next Topic:How to use outer joins in named query to calculate aggregate values?
Goto Forum:

Current Time: Fri Apr 16 03:42:47 GMT 2021

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

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

Back to the top