On Tue, Jun 5, 2018 at 1:06 PM, Sanne Grinovero <sa...@hibernate.org> wrote:

> On 5 June 2018 at 14:43, Scott Marlow <smar...@redhat.com> wrote:
> > The PersistenceUnitInfo#addTransformer javadoc [1] mentions:
> >
> > "
> > Add a transformer supplied by the provider that will be called for every
> > new class definition or class redefinition that gets loaded by the loader
> > returned by the getClassLoader()
> > <https://docs.oracle.com/javaee/7/api/javax/persistence/spi/
> PersistenceUnitInfo.html#getClassLoader-->
> > method. The transformer has no effect on the result returned by the
> > getNewTempClassLoader()
> > <https://docs.oracle.com/javaee/7/api/javax/persistence/spi/
> PersistenceUnitInfo.html#getNewTempClassLoader-->
> > method. Classes are only transformed once within the same classloading
> > scope, regardless of how many persistence units they may be a part of.
> > "
> >
> > Should we have a check somewhere that prevents the same entity class from
> > being enhanced multiple times?  Should the check be in the JPA container
> or
> > in the persistence provider?  Thought I would check here in case anyone
> > remembers the background of where the check was intended to be exactly.
>
> I suspect it's necessary to do this check in the container.
>

For WildFly, the checking would be important when there are multiple
persistence units that include the same entity class(es), to ensure that
only one thread does the transformation, however, the
Hibernate org.hibernate.engine.spi.Managed marker interface may provide
enough protection.



>
> If you do it in the persistence provider, how can you guarantee that
> another persistence provider is not keeping track independently?
>
> > I assume that WildFly might be the best place to have the check but
> wanted
> > to ask here first, because if the JPA container does the checking, that
> > will mean that ORM will only be able to register one class transformer
> per
> > persistence unit.  WildFly will also have to prevent other persistence
> > units from transforming the same entity class in a different thread (e.g.
> > since we typically deploy all of the persistence units in parallel, we
> will
> > need some synchronization).
>
> +1
>
> >
> > Scott
> >
> > [1]
> > https://docs.oracle.com/javaee/7/api/javax/persistence/spi/
> PersistenceUnitInfo.html#addTransformer-javax.persistence.spi.
> ClassTransformer-
> >
> > [2] https://github.com/wildfly/wildfly/pull/11297
> > _______________________________________________
> > hibernate-dev mailing list
> > hibernate-dev@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to