Hi Craig,

> It looks like the DN enhancer recognizes the annotation as a
> persistence-capable class because it is annotated with PersistenceCapable
> but doesn't recognize it as an annotation that should not be enhanced.

Quite probably. I've only been enhancing through a persistence.xml file 
recently, which explicitly specifies the classes to be enhanced so never hit 
that one.

> I looked at the code and think that perhaps a patch like this would fix it.
> org.datanucleus.enhancer.ClassEnhancerImpl around line 298 after the cls
> object is obtained:
> 
>         if (cls.isAnnotation())
>         {
>             return false;
>         }
> 
> Other possible solutions: move the composite annotations out of the package
> into a sibling package. This probably works but is awkward.

No, let's just fix the code rather than imposing the user has to do something.

Instead of doing your proposed fix, I put a couple of checks in further 
upstream, where it reads annotations for a class to check if it is has 
metadata. 

See https://github.com/datanucleus/datanucleus-core/commit/
f048a37494066b46545a1849d536104dc149950d

A simple test with that fix, explicitly adding the meta-annotation class to 
persistence.xml results in a log message that the class has no metadata and is 
ignored.

That should be in current DN nightly builds, so give it a try and see if it 
catches your situation. 




Regards
-- 
Andy
DataNucleus (Web: http://www.datanucleus.org   Twitter: @datanucleus)

Reply via email to