List of usage examples for javax.persistence EntityManager isJoinedToTransaction
public boolean isJoinedToTransaction();
From source file:com.github.fharms.camel.entitymanager.CamelEntityManagerHandler.java
private <T> T createEntityManagerProxy(Class<T> interfaceClass, Object emProxy) { InvocationHandler handler = (proxy, method, args) -> { EntityManager em = entityManagerLocal.get() != null ? entityManagerLocal.get() : (EntityManager) emProxy; switch (method.getName()) { case "hashCode": return hashCode(); case "equals": return (em == args[0]); case "toString": return "Camel EntityManager proxy [" + em.toString() + "]"; }/*from w ww . j a v a 2s . co m*/ if (!em.isJoinedToTransaction()) { em.joinTransaction(); } return method.invoke(em, args); }; return (T) Proxy.newProxyInstance(interfaceClass.getClassLoader(), new Class[] { interfaceClass }, handler); }