Author: pete.muir(a)jboss.org
Date: 2010-09-27 11:28:45 -0400 (Mon, 27 Sep 2010)
New Revision: 13782
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
Log:
work around lack of conversation context
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
===================================================================
---
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-09-26
22:25:36 UTC (rev 13781)
+++
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-09-27
15:28:45 UTC (rev 13782)
@@ -110,10 +110,19 @@
EntityManagerFactory emf = getEntityManagerFactory();
EntityManager entityManager = emf.createEntityManager();
entityManager =
getPersistenceProvider(entityManager).proxyEntityManager(entityManager);
- ManagedPersistenceContextProxyHandler handler = new
ManagedPersistenceContextProxyHandler(entityManager, manager, bean.getQualifiers(),
getPersistenceContexts(), getPersistenceProvider(entityManager));
+ PersistenceContexts persistenceContexts = null;
+ try
+ {
+ persistenceContexts = getPersistenceContexts();
+ }
+ catch (ContextNotActiveException e)
+ {
+ // it's null already
+ }
+ ManagedPersistenceContextProxyHandler handler = new
ManagedPersistenceContextProxyHandler(entityManager, manager, bean.getQualifiers(),
persistenceContexts, getPersistenceProvider(entityManager));
EntityManager proxy = (EntityManager) proxyConstructor.newInstance(handler);
arg0.push(proxy);
- getPersistenceProvider(entityManager).setFlushMode(proxy,
getPersistenceContexts().getFlushMode());
+ getPersistenceProvider(entityManager).setFlushMode(proxy, getFlushMode());
manager.fireEvent(new SeamManagedPersistenceContextCreated(proxy), qualifiers);
return proxy;
@@ -123,6 +132,19 @@
throw new RuntimeException(e);
}
}
+
+ private FlushModeType getFlushMode()
+ {
+ try
+ {
+ return getPersistenceContexts().getFlushMode();
+ }
+ catch (ContextNotActiveException e)
+ {
+ // TODO Set the default flush mode for the app
+ return FlushModeType.AUTO;
+ }
+ }
public void destroy(Bean<EntityManager> bean, EntityManager em,
CreationalContext<EntityManager> arg1)
{
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java
===================================================================
---
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java 2010-09-26
22:25:36 UTC (rev 13781)
+++
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextProxyHandler.java 2010-09-27
15:28:45 UTC (rev 13782)
@@ -173,7 +173,10 @@
{
// we need to do this first to prevent an infinite loop
persistenceContextsTouched = true;
- persistenceContexts.touch(delegate);
+ if (persistenceContexts != null)
+ {
+ persistenceContexts.touch(delegate);
+ }
}
catch (ContextNotActiveException e)
{
Show replies by date