Hi,
I need an advice on using DMI with JPA2.
I need to create and close entityManager for each request in order to pick up database changes made by others.
One way to do it is to close the entity manager at the end of DMI method but this causes en exception because of lazy loading of JPA(currently hibernate) needs to have the entity manager which loaded it open. I need to close it after datasource serialized data from entities.
Is there any callback I could use? Is there a better way?
At the moment I assume that DMI calls use thread pool at the server side. Am I correct? Or will DMI invocation create a new thread each time?
At the moment my implementation is
I need an advice on using DMI with JPA2.
I need to create and close entityManager for each request in order to pick up database changes made by others.
One way to do it is to close the entity manager at the end of DMI method but this causes en exception because of lazy loading of JPA(currently hibernate) needs to have the entity manager which loaded it open. I need to close it after datasource serialized data from entities.
Is there any callback I could use? Is there a better way?
At the moment I assume that DMI calls use thread pool at the server side. Am I correct? Or will DMI invocation create a new thread each time?
At the moment my implementation is
Code:
static { emf = Persistence.createEntityManagerFactory("smartRISE"); threadLocal = new ThreadLocal<EntityManager>(); logger = Logger.getLogger("smartRISE"); logger.setLevel(Level.ALL); } public static EntityManager getEntityManager() { EntityManager manager = threadLocal.get(); if (manager == null || !manager.isOpen()) { manager = emf.createEntityManager(); manager.setFlushMode(FlushModeType.COMMIT); threadLocal.set(manager); } return manager; }
Comment