You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Patrick Linskey (JIRA)" <ji...@apache.org> on 2006/10/31 10:58:17 UTC

[jira] Commented: (OPENJPA-72) PersistenceProviderImpl.createContainerEntityManagerFactory() should not add a ClassTransformerImpl to PersistenceUnitInfo if

    [ http://issues.apache.org/jira/browse/OPENJPA-72?page=comments#action_12445857 ] 
            
Patrick Linskey commented on OPENJPA-72:
----------------------------------------

Actually, <exclude-unlisted-classes>true</exclude-unlisted-classes> is a directive that tells OpenJPA not to scan your jars for classes marked up as @Entity. IIRC, by default, OpenJPA only does runtime enhancement if classes are enumerated, so this might be indirectly causing your problem.

I thought that there was an OpenJPA configuration setting that could be used to turn off this behavior, but I don't see it.

It would seem that it'd be good to either have an option in Spring to control whether or not the weaver gets added, or to do some work (if possible) before registering the ClassTransformer to see if all the classes are already persistence-capable.

> PersistenceProviderImpl.createContainerEntityManagerFactory() should not add a ClassTransformerImpl to PersistenceUnitInfo if <exclude-unlisted-classes>
> --------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-72
>                 URL: http://issues.apache.org/jira/browse/OPENJPA-72
>             Project: OpenJPA
>          Issue Type: Bug
>         Environment: JDK1.5, Win32, openjpa-0.9.0-incubating
>            Reporter: Corey Klaasmeyer
>
> Adding a transformer is unnecessary if classes are enhanced at build time. As far as I can tell, you specify this by adding the <exclude-unlisted-classes> property to persistence.xml. This could probably be made more clear by calling the property something like "build-time-enhancement-only" or "disable-runtime-enhancement". Additionally, this causes a Spring configured JPA to fail with and IllegalStateException if no LoadTimeWeaver is specified in the LocalContainerEntityManagerFactory. The relevent code is on line 93 of PersistenceProviderImpl
>     public EntityManagerFactory createContainerEntityManagerFactory(
>         PersistenceUnitInfo pui, Map m) {
>         PersistenceProductDerivation pd = new PersistenceProductDerivation();
>         try {
>             ConfigurationProvider cp = pd.load(pui, m);
>             if (cp == null)
>                 return null;
>             // add enhancer
>             String ctOpts = (String) Configurations.getProperty
>                 (CLASS_TRANSFORMER_OPTIONS, pui.getProperties());
>             pui.addTransformer(new ClassTransformerImpl(cp, ctOpts, 
>                 pui.getNewTempClassLoader()));
>             BrokerFactory factory = Bootstrap.newBrokerFactory(cp, 
>                 pui.getClassLoader());
>             return OpenJPAPersistence.toEntityManagerFactory(factory);
>         } catch (Exception e) {
>             throw PersistenceExceptions.toPersistenceException(e);
>         }
>     }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira