Search code examples
openjpaopenejb

Is there Any Way to Enforce RuntimeUnenhancedClasses in EE Configuration


I just spent a half hour debugging some new code that's not broken because I forgot to check (again!) my logs for this dreaded message:

 WARN   openjpa.Enhance - Creating subclass for ...

I'm running OpenJPA 2.1.0 inside an OpenEJB 3.2 snapshot build, Java 1.6.0_25, and Eclipse Helios. My entities are enhanced using the ant PCEnhancerTask.

My META-INF/openjpa.xml contains

 <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported" />
 <property name="openjpa.DynamicEnhancementAgent" value="false" />

Is there anyway with this EE configuration to have OpenJPA enforce the RuntimeUnenhancedClasses option as it does in an SE configuration?

I suspect my 'real' problem stems from an Eclipse svn update that sometimes touches my JPA entity source, causing a build that overwrites my enhanced classes.

It's frustrating how often I run a unit test from the IDE that fails in some weird way, and I go digging through my code looking for a problem when all I need to do is run the enhancer.


Solution

  • Put the <property name="openjpa.RuntimeUnenhancedClasses" value="unsupported" /> META-INF/persistence.xml.

    Looks like we're logging this action on debug level (maybe it should be info level), but OpenEJB will set that property to the default as it was in OpenJPA 1.x so that apps that worked with OpenEJB 3.1.x/OpenJPA 1.x will still work without modification in 3.2.x. If the property is already set in the persistence.xml it will never be overridden, so setting it there will have the effect you want.

    Open to suggestions on how to save others in the same boat some time in the future. Seems either looking in the openjpa.xml file and seeing the property set already or issuing the log message on info would do it -- or both.