Hi,
I'm using:
hibernate-3.2.6.GA
hibernate-entitymanager-3.3.2.GA
How to instantiate a single EntityManager in an interceptor?
Hibernate's OpenSession() method does take parameter of type "Interceptor", but createEntityManager() doesn't.
Please advise.
Below is the code for interceptor. I'm trying to convert HibernateUtil so that I can use JPA EntityManagerFactory and EntityManager. In HibernateUtil, I instantiate like below. But don't know how when come to createEntityeManager
Code:
s = getSessionFactory().openSession(getInterceptor());
Code:
/**
* Register a Hibernate interceptor with the current thread.
* <p>
* Every Session opened is opened with this interceptor after
* registration. Has no effect if the current Session of the
* thread is already open, effective on next close()/getSession().
*/
public static void registerInterceptor(Interceptor interceptor) {
threadInterceptor.set(interceptor);
}
private static Interceptor getInterceptor() {
Interceptor interceptor =
(Interceptor) threadInterceptor.get();
return interceptor;
}
Regards,
Jap.