[jira] [Updated] (TAP5-2027) EntityManagerObjectProvider always provides the initial EntityManger proxy created

2016-03-14 Thread Kalle Korhonen (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-2027?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kalle Korhonen updated TAP5-2027:
-
Fix Version/s: 5.4.1

> EntityManagerObjectProvider always provides the initial EntityManger proxy 
> created
> --
>
> Key: TAP5-2027
> URL: https://issues.apache.org/jira/browse/TAP5-2027
> Project: Tapestry 5
>  Issue Type: Bug
>  Components: tapestry-jpa
>Affects Versions: 5.3.5, 5.3.6, 5.4
>Reporter: John Coleman
>Assignee: Kalle Korhonen
> Fix For: 5.4.1
>
> Attachments: TapestryJPATest.zip
>
>
> When persistence.xml defines multiple persistence units, classes injecting 
> EntityManager with @PersistenceContext(unitName=value  crash because the 
> entities associated with the PU in configuration are not recognised at 
> runtime.
> By placing trace in the code I established that the first EntityManager 
> injected gets injected to all my other service classes even though I use 
> different unitName= annotations.
> The EntityManagerObjectProvider class contains a class variable proxy and 
> works like a singleton always injecting the first EntityManager proxy class 
> created for any later EntityManager injections.
> The following code fixes the issue and is provided as-is, free and without 
> copyright or warranty. This is more like a refactor because I have also 
> replaced some depricated code. As a patch it also works just to remove the 
> proxy class member variable and the if (proxy == null) condition.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (TAP5-2027) EntityManagerObjectProvider always provides the initial EntityManger proxy created

2016-03-14 Thread Kalle Korhonen (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-2027?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kalle Korhonen updated TAP5-2027:
-
Affects Version/s: 5.4

> EntityManagerObjectProvider always provides the initial EntityManger proxy 
> created
> --
>
> Key: TAP5-2027
> URL: https://issues.apache.org/jira/browse/TAP5-2027
> Project: Tapestry 5
>  Issue Type: Bug
>  Components: tapestry-jpa
>Affects Versions: 5.3.5, 5.3.6, 5.4
>Reporter: John Coleman
>Assignee: Kalle Korhonen
> Attachments: TapestryJPATest.zip
>
>
> When persistence.xml defines multiple persistence units, classes injecting 
> EntityManager with @PersistenceContext(unitName=value  crash because the 
> entities associated with the PU in configuration are not recognised at 
> runtime.
> By placing trace in the code I established that the first EntityManager 
> injected gets injected to all my other service classes even though I use 
> different unitName= annotations.
> The EntityManagerObjectProvider class contains a class variable proxy and 
> works like a singleton always injecting the first EntityManager proxy class 
> created for any later EntityManager injections.
> The following code fixes the issue and is provided as-is, free and without 
> copyright or warranty. This is more like a refactor because I have also 
> replaced some depricated code. As a patch it also works just to remove the 
> proxy class member variable and the if (proxy == null) condition.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (TAP5-2027) EntityManagerObjectProvider always provides the initial EntityManger proxy created

2016-03-14 Thread Kalle Korhonen (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-2027?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kalle Korhonen updated TAP5-2027:
-
Labels:   (was: bulk-close-candidate)

> EntityManagerObjectProvider always provides the initial EntityManger proxy 
> created
> --
>
> Key: TAP5-2027
> URL: https://issues.apache.org/jira/browse/TAP5-2027
> Project: Tapestry 5
>  Issue Type: Bug
>  Components: tapestry-jpa
>Affects Versions: 5.3.5, 5.3.6, 5.4
>Reporter: John Coleman
>Assignee: Kalle Korhonen
> Attachments: TapestryJPATest.zip
>
>
> When persistence.xml defines multiple persistence units, classes injecting 
> EntityManager with @PersistenceContext(unitName=value  crash because the 
> entities associated with the PU in configuration are not recognised at 
> runtime.
> By placing trace in the code I established that the first EntityManager 
> injected gets injected to all my other service classes even though I use 
> different unitName= annotations.
> The EntityManagerObjectProvider class contains a class variable proxy and 
> works like a singleton always injecting the first EntityManager proxy class 
> created for any later EntityManager injections.
> The following code fixes the issue and is provided as-is, free and without 
> copyright or warranty. This is more like a refactor because I have also 
> replaced some depricated code. As a patch it also works just to remove the 
> proxy class member variable and the if (proxy == null) condition.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (TAP5-2027) EntityManagerObjectProvider always provides the initial EntityManger proxy created

2016-02-22 Thread Jochen Kemnade (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-2027?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jochen Kemnade updated TAP5-2027:
-
Labels: bulk-close-candidate  (was: patch)

This issue affects an old version of Tapestry that is not actively developed 
anymore, and is therefore prone to be bulk-closed in the near future.

If the issue still persists with the most recent version of Tapestry (currently 
5.4.0, available from Maven Central), please update it as soon as possible and 
add '5.4.0') to the issue's affected versions.

> EntityManagerObjectProvider always provides the initial EntityManger proxy 
> created
> --
>
> Key: TAP5-2027
> URL: https://issues.apache.org/jira/browse/TAP5-2027
> Project: Tapestry 5
>  Issue Type: Bug
>  Components: tapestry-jpa
>Affects Versions: 5.3.5, 5.3.6
>Reporter: John Coleman
>Assignee: Kalle Korhonen
>  Labels: bulk-close-candidate
> Attachments: TapestryJPATest.zip
>
>
> When persistence.xml defines multiple persistence units, classes injecting 
> EntityManager with @PersistenceContext(unitName=value  crash because the 
> entities associated with the PU in configuration are not recognised at 
> runtime.
> By placing trace in the code I established that the first EntityManager 
> injected gets injected to all my other service classes even though I use 
> different unitName= annotations.
> The EntityManagerObjectProvider class contains a class variable proxy and 
> works like a singleton always injecting the first EntityManager proxy class 
> created for any later EntityManager injections.
> The following code fixes the issue and is provided as-is, free and without 
> copyright or warranty. This is more like a refactor because I have also 
> replaced some depricated code. As a patch it also works just to remove the 
> proxy class member variable and the if (proxy == null) condition.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Updated] (TAP5-2027) EntityManagerObjectProvider always provides the initial EntityManger proxy created

2012-11-15 Thread John Coleman (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-2027?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

John Coleman updated TAP5-2027:
---

Description: 
When persistence.xml defines multiple persistence units, classes injecting 
EntityManager with @PersistenceContext(unitName=value  crash because the 
entities associated with the PU in configuration are not recognised at runtime.

By placing trace in the code I established that the first EntityManager 
injected gets injected to all my other service classes even though I use 
different unitName= annotations.

The EntityManagerObjectProvider class contains a class variable proxy and works 
like a singleton always injecting the first EntityManager proxy class created 
for any later EntityManager injections.

The following code fixes the issue and is provided as-is, free and without 
copyright or warranty. This is more like a refactor because I have also 
replaced some depricated code. As a patch it also works just to remove the 
proxy class member variable and the if (proxy == null) condition.





  was:
When persistence.xml defines multiple persistence units, classes injecting 
EntityManager with @PersistenceContext(unitName=value  crash because the 
entities associated with the PU in configuration are not recognised at runtime.

By placing trace in the code I established that the first EntityManager 
injected gets injected to all my other service classes even though I use 
different unitName= annotations.

The EntityManagerObjectProvider class contains a class variable proxy and works 
like a singleton always injecting the first EntityManager proxy class created 
for any later EntityManager injections.

The following code fixes the issue and is provided as-is, free and without 
copyright or warranty. This is more like a refactor because I have also 
replaced some depricated code. As a patch it also works just to remove the 
proxy class member variable and the if (proxy == null) condition.


package org.apache.tapestry5.internal.jpa;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.tapestry5.ioc.AnnotationProvider;
import org.apache.tapestry5.ioc.ObjectCreator;
import org.apache.tapestry5.ioc.ObjectLocator;
import org.apache.tapestry5.ioc.ObjectProvider;
import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
import org.apache.tapestry5.jpa.EntityManagerManager;

/**
 * A patched version to use PlasticProxyFactory and not cache the 
EntityManager as a class member.
 * @author John Coleman
 */
public class EntityManagerObjectProvider implements ObjectProvider
{

/**
 * {@inheritDoc}
 */
public  T provide(final Class objectType, final AnnotationProvider 
annotationProvider,
final ObjectLocator locator)
{
if (objectType.equals(EntityManager.class))
return objectType.cast(getOrCreateProxy(annotationProvider, 
locator));

return null;
}

private synchronized EntityManager getOrCreateProxy(
final AnnotationProvider annotationProvider, final ObjectLocator 
objectLocator)
{
final PlasticProxyFactory proxyFactory = 
objectLocator.getService("PlasticProxyFactory",
  PlasticProxyFactory.class);

 final PersistenceContext annotation = annotationProvider
.getAnnotation(PersistenceContext.class);

EntityManager proxy = 
proxyFactory.createProxy(EntityManager.class, new 
ObjectCreator()
{
public EntityManager createObject()
{
final EntityManagerManager entityManagerManager = 
objectLocator
.getService(EntityManagerManager.class);

return 
JpaInternalUtils.getEntityManager(entityManagerManager, annotation);
}
}, "");

return proxy;
}

} 





> EntityManagerObjectProvider always provides the initial EntityManger proxy 
> created
> --
>
> Key: TAP5-2027
> URL: https://issues.apache.org/jira/browse/TAP5-2027
> Project: Tapestry 5
>  Issue Type: Bug
>  Components: tapestry-jpa
>Affects Versions: 5.3.5, 5.3.6
>Reporter: John Coleman
>  Labels: patch
> Attachments: TapestryJPATest.zip
>
>
> When persistence.xml defines multiple persistence units, classes injecting 
> EntityManager with @PersistenceContext(unitName=value  crash because the 
> entities associated with the PU in configuration are not recognised at 
> runtime.
> By placing trace in the code I established that the first EntityManager 
> injected gets injected to all my other service classes even though I use 
> different unitName= annotations.
> The EntityManagerObjectProvider class contains a class variable proxy an

[jira] [Updated] (TAP5-2027) EntityManagerObjectProvider always provides the initial EntityManger proxy created

2012-11-15 Thread John Coleman (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-2027?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

John Coleman updated TAP5-2027:
---

Attachment: TapestryJPATest.zip

navigate to the Alpha page, then the Beta page - the BetaDAO gets a reference 
to the Alpha DB unit

> EntityManagerObjectProvider always provides the initial EntityManger proxy 
> created
> --
>
> Key: TAP5-2027
> URL: https://issues.apache.org/jira/browse/TAP5-2027
> Project: Tapestry 5
>  Issue Type: Bug
>  Components: tapestry-jpa
>Affects Versions: 5.3.5, 5.3.6
>Reporter: John Coleman
>  Labels: patch
> Attachments: TapestryJPATest.zip
>
>
> When persistence.xml defines multiple persistence units, classes injecting 
> EntityManager with @PersistenceContext(unitName=value  crash because the 
> entities associated with the PU in configuration are not recognised at 
> runtime.
> By placing trace in the code I established that the first EntityManager 
> injected gets injected to all my other service classes even though I use 
> different unitName= annotations.
> The EntityManagerObjectProvider class contains a class variable proxy and 
> works like a singleton always injecting the first EntityManager proxy class 
> created for any later EntityManager injections.
> The following code fixes the issue and is provided as-is, free and without 
> copyright or warranty. This is more like a refactor because I have also 
> replaced some depricated code. As a patch it also works just to remove the 
> proxy class member variable and the if (proxy == null) condition.
> package org.apache.tapestry5.internal.jpa;
> import javax.persistence.EntityManager;
> import javax.persistence.PersistenceContext;
> import org.apache.tapestry5.ioc.AnnotationProvider;
> import org.apache.tapestry5.ioc.ObjectCreator;
> import org.apache.tapestry5.ioc.ObjectLocator;
> import org.apache.tapestry5.ioc.ObjectProvider;
> import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
> import org.apache.tapestry5.jpa.EntityManagerManager;
> /**
>  * A patched version to use PlasticProxyFactory and not cache the 
> EntityManager as a class member.
>  * @author John Coleman
>  */
> public class EntityManagerObjectProvider implements ObjectProvider
> {
> /**
>  * {@inheritDoc}
>  */
> public  T provide(final Class objectType, final AnnotationProvider 
> annotationProvider,
> final ObjectLocator locator)
> {
> if (objectType.equals(EntityManager.class))
> return objectType.cast(getOrCreateProxy(annotationProvider, 
> locator));
> return null;
> }
> private synchronized EntityManager getOrCreateProxy(
> final AnnotationProvider annotationProvider, final ObjectLocator 
> objectLocator)
> {
> final PlasticProxyFactory proxyFactory = 
> objectLocator.getService("PlasticProxyFactory",
>   PlasticProxyFactory.class);
>  final PersistenceContext annotation = annotationProvider
> .getAnnotation(PersistenceContext.class);
> EntityManager proxy = 
> proxyFactory.createProxy(EntityManager.class, new 
> ObjectCreator()
> {
> public EntityManager createObject()
> {
> final EntityManagerManager entityManagerManager = 
> objectLocator
> .getService(EntityManagerManager.class);
> return 
> JpaInternalUtils.getEntityManager(entityManagerManager, annotation);
> }
> }, "");
> return proxy;
> }
> } 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


[jira] [Updated] (TAP5-2027) EntityManagerObjectProvider always provides the initial EntityManger proxy created

2012-11-13 Thread John Coleman (JIRA)

 [ 
https://issues.apache.org/jira/browse/TAP5-2027?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

John Coleman updated TAP5-2027:
---

Description: 
When persistence.xml defines multiple persistence units, classes injecting 
EntityManager with @PersistenceContext(unitName=value  crash because the 
entities associated with the PU in configuration are not recognised at runtime.

By placing trace in the code I established that the first EntityManager 
injected gets injected to all my other service classes even though I use 
different unitName= annotations.

The EntityManagerObjectProvider class contains a class variable proxy and works 
like a singleton always injecting the first EntityManager proxy class created 
for any later EntityManager injections.

The following code fixes the issue and is provided as-is, free and without 
copyright or warranty. This is more like a refactor because I have also 
replaced some depricated code. As a patch it also works just to remove the 
proxy class member variable and the if (proxy == null) condition.


package org.apache.tapestry5.internal.jpa;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.tapestry5.ioc.AnnotationProvider;
import org.apache.tapestry5.ioc.ObjectCreator;
import org.apache.tapestry5.ioc.ObjectLocator;
import org.apache.tapestry5.ioc.ObjectProvider;
import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
import org.apache.tapestry5.jpa.EntityManagerManager;

/**
 * A patched version to use PlasticProxyFactory and not cache the 
EntityManager as a class member.
 * @author John Coleman
 */
public class EntityManagerObjectProvider implements ObjectProvider
{

/**
 * {@inheritDoc}
 */
public  T provide(final Class objectType, final AnnotationProvider 
annotationProvider,
final ObjectLocator locator)
{
if (objectType.equals(EntityManager.class))
return objectType.cast(getOrCreateProxy(annotationProvider, 
locator));

return null;
}

private synchronized EntityManager getOrCreateProxy(
final AnnotationProvider annotationProvider, final ObjectLocator 
objectLocator)
{
final PlasticProxyFactory proxyFactory = 
objectLocator.getService("PlasticProxyFactory",
  PlasticProxyFactory.class);

 final PersistenceContext annotation = annotationProvider
.getAnnotation(PersistenceContext.class);

EntityManager proxy = 
proxyFactory.createProxy(EntityManager.class, new 
ObjectCreator()
{
public EntityManager createObject()
{
final EntityManagerManager entityManagerManager = 
objectLocator
.getService(EntityManagerManager.class);

return 
JpaInternalUtils.getEntityManager(entityManagerManager, annotation);
}
}, "");

return proxy;
}

} 




  was:
When persistence.xml defines multiple persistence units, classes injecting 
EntityManager with @PersistenceContext(unitName=value  crash because the 
entities associated with the PU in configuration are not recognised at runtime.

By placing trace in the code I established that the first EntityManager 
injected gets injected to all my other service classes even though I use 
different unitName= annotations.

The EntityManagerObjectProvider class contains a class variable proxy and works 
like a singleton always injecting the first EntityManager proxy class created 
for any later EntityManager injections.

The following patch fixes the issue and is provided as-is, free and without 
copyright or warranty:


package org.apache.tapestry5.internal.jpa;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.tapestry5.ioc.AnnotationProvider;
import org.apache.tapestry5.ioc.ObjectCreator;
import org.apache.tapestry5.ioc.ObjectLocator;
import org.apache.tapestry5.ioc.ObjectProvider;
import org.apache.tapestry5.ioc.services.PlasticProxyFactory;
import org.apache.tapestry5.jpa.EntityManagerManager;

/**
 * A patched version to use PlasticProxyFactory and not cache the 
EntityManager as a class member.
 * @author John Coleman
 */
public class EntityManagerObjectProvider implements ObjectProvider
{

/**
 * {@inheritDoc}
 */
public  T provide(final Class objectType, final AnnotationProvider 
annotationProvider,
final ObjectLocator locator)
{
if (objectType.equals(EntityManager.class))
return objectType.cast(getOrCreateProxy(annotationProvider, 
locator));

return null;
}

private synchronized EntityManager getOrCreateProxy(
final AnnotationProvider annotationProvider, final ObjectLocator 
objectLocator)
{
final PlasticProxyFactory proxyFactory = 
objectLocator.getService("Pl