[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] Cache issue

Dear all,

I have a problem when I enable the eclipselink cache default one).

All my CRUD (Create, Read, Update and Delete) are implemented instantiating and closing an EntityManager. For example:

public final T findById(I id) {
           	
	EntityManager entityManager = JpaManager.getManager();
	
	try {			
		return (T)  entityManager.find(entityClass, id);	
	}catch(Exception ex){
		....
	} finally {
		entityManager.close();
	}		
	return null;
}


public final void save(final T object) {

	EntityManager entityManager = JpaManager.getManager();
		
	try {
		entityManager.getTransaction().begin();

		entityManager.persist(object);
					
		entityManager.getTransaction().commit();			
	}catch(Exception ex){
		entityManager.getTransaction().rollback();
		......
	}finally {
		entityManager.close();
	}
}


It happens that sometimes I save an object and then I load (e.g. findBtyId) but the retrieved value in not updated (that is, it is not the last value I have saved or updated). On the DB, the table contain the right value (the last saved).



I've tried to disable the cache in the persistence.xml file:

<property name="eclipselink.cache.type.default" value="None"/>

and all is going well.

Any help about?I need to configure the cache differently basing on the structure of my code?)

BR,
Enrico