You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Craig Russell <ap...@gmail.com> on 2017/07/20 00:46:24 UTC

Issue with enhancement of annotations

Hi,

I'm trying to run the tck including this composite annotation:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@javax.jdo.annotations.PersistenceCapable(detachable="true", identityType=IdentityType.DATASTORE)
@javax.jdo.annotations.DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY")
@javax.jdo.annotations.Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, column="DISCRIMINATOR", indexed="true")
@javax.jdo.annotations.Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE)

public @interface DatastoreIdDiscriminatorClassNameInheritanceSuperclass { }

When I run the enhancement step, it complains:

Failed to execute goal org.apache.jdo:jdo-exectck:3.2-SNAPSHOT:enhance (default) on project jdo-tck: Execution default of goal org.apache.jdo:jdo-exectck:3.2-SNAPSHOT:enhance failed: Class "org.apache.jdo.tck.pc.companyAnnotatedFC.DatastoreIdDiscriminatorClassNameInheritanceSuperclass" has been specified with an inheritance strategy of "superclass-table", yet no superclass exists or none exists with its own table! -> [Help 1]

It looks like the enhancer is trying to enhance this class, but it should not. An annotation cannot be persistent so it should not be enhanced.

Any ideas?

Thanks,

Craig

Craig L Russell
clr@apache.org


Re: Issue with enhancement of annotations

Posted by Craig Russell <ap...@gmail.com>.
Hi Andy,

> On Jul 21, 2017, at 8:05 AM, Andy Jefferson <an...@datanucleus.org> wrote:
> 
>> I updated the pom.xml to 5.1.1-SNAPSHOT and the enhancer step worked but
>> many tck tests fail. [1]
> 
> I'd suggest that is down to whatever is different in your TCK from the SVN 
> trunk TCK ...

Clearly this is the case. The class/interface/annotation that is being complained about is the new composite annotation.

The failure is in a subclass of a class that has the new annotation. FCDSMedicalInsurance extends FCDSInsurance.

I've prepared a patch that shows the error. Can you please try it and let me know what you think the problem is.

https://issues.apache.org/jira/browse/JDO-764

Thanks,

Craig

[1]
Insert of object "org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSMedicalInsurance@5553d0f5" using statement "INSERT INTO DATASTOREIDENTITY0.FCDSINSURANCE (CARRIER,EMPLOYEE,INSID,PLANTYPE,DISCRIMINATOR) VALUES (?,?,?,?,?)" failed : Table/View 'DATASTOREIDENTITY0.FCDSINSURANCE' does not exist.
org.datanucleus.exceptions.NucleusDataStoreException: Insert of object "org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSMedicalInsurance@5553d0f5" using statement "INSERT INTO DATASTOREIDENTITY0.FCDSINSURANCE (CARRIER,EMPLOYEE,INSID,PLANTYPE,DISCRIMINATOR) VALUES (?,?,?,?,?)" failed : Table/View 'DATASTOREIDENTITY0.FCDSINSURANCE' does not exist.


Re: Issue with enhancement of annotations

Posted by Andy Jefferson <an...@datanucleus.org>.
> I updated the pom.xml to 5.1.1-SNAPSHOT and the enhancer step worked but
> many tck tests fail. [1]

I'd suggest that is down to whatever is different in your TCK from the SVN 
trunk TCK ... because SVN trunk works fine with current DN code, and the only 
change in my fix is ignoring classes that are annotations, hence no 
persistable classes will be ignored due to this check.


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

Re: Issue with enhancement of annotations

Posted by Craig Russell <ap...@gmail.com>.
Hi Andy,

> On Jul 20, 2017, at 11:40 PM, Andy Jefferson <an...@datanucleus.org> wrote:
> 
> 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.

I agree. That didn't work anyway (see subsequent message for details).
> 
> 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. 

I updated the pom.xml to 5.1.1-SNAPSHOT and the enhancer step worked but many tck tests fail. [1]

Thanks,

Craig

09:58:35,295 (main) INFO  [DataNucleus.JDO] - Exception thrown
Class "org.apache.jdo.tck.pc.companyAnnotatedFC.DatastoreIdDiscriminatorClassNameInheritanceSuperclass" has been specified with an inheritance strategy of "superclass-table", yet no superclass exists or none exists with its own table!
org.datanucleus.metadata.InvalidClassMetaDataException: Class "org.apache.jdo.tck.pc.companyAnnotatedFC.DatastoreIdDiscriminatorClassNameInheritanceSuperclass" has been specified with an inheritance strategy of "superclass-table", yet no superclass exists or none exists with its own table!
	at org.datanucleus.metadata.AbstractClassMetaData.validateUserInputForInheritanceMetaData(AbstractClassMetaData.java:874)
	at org.datanucleus.metadata.InterfaceMetaData.populate(InterfaceMetaData.java:120)
	at org.datanucleus.metadata.MetaDataManagerImpl$1.run(MetaDataManagerImpl.java:2926)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.datanucleus.metadata.MetaDataManagerImpl.populateAbstractClassMetaData(MetaDataManagerImpl.java:2920)
	at org.datanucleus.metadata.MetaDataManagerImpl.populateFileMetaData(MetaDataManagerImpl.java:2724)
	at org.datanucleus.metadata.MetaDataManagerImpl.initialiseFileMetaDataForUse(MetaDataManagerImpl.java:1365)
	at org.datanucleus.metadata.MetaDataManagerImpl.loadClasses(MetaDataManagerImpl.java:645)
	at org.datanucleus.enhancer.DataNucleusEnhancer.getFileMetadataForInput(DataNucleusEnhancer.java:672)
	at org.datanucleus.enhancer.DataNucleusEnhancer.enhance(DataNucleusEnhancer.java:500)
	at org.datanucleus.api.jdo.JDOEnhancer.enhance(JDOEnhancer.java:125)
	at org.apache.jdo.exectck.Enhance.execute(Enhance.java:288)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

*> Running tests for runonce.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for instancecallbacks.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for jdohelper.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for pm.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for pmf.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for detach.conf with datastoreidentity on 'derby' mapping=8 ... success
*> Running tests for embeddedInheritance.conf with datastoreidentity on 'derby' mapping=12 ... success
*> Running tests for enhancement.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for extents.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for fetchplan.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for fetchgroup.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for lifecycle.conf with datastoreidentity on 'derby' mapping= ... FAIL
*> Running tests for models.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for models1.conf with datastoreidentity on 'derby' mapping=1 ... success
*> Running tests for query.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for jdoql.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for jdoql1.conf with datastoreidentity on 'derby' mapping=1 ... success
*> Running tests for transactions.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyNoRelationships.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyEmbedded.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for company1-1Relationships.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for company1-MRelationships.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyM-MRelationships.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAllRelationships.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyMapWithoutJoin.conf with datastoreidentity on 'derby' mapping=9 ... success
*> Running tests for companyListWithoutJoin.conf with datastoreidentity on 'derby' mapping=10 ... success
*> Running tests for companyPMClass.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyPMInterface.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotated1-1RelationshipsFCPM.conf with datastoreidentity on 'derby' mapping= ... FAIL
*> Running tests for companyAnnotated1-MRelationshipsFCPM.conf with datastoreidentity on 'derby' mapping= ... FAIL
*> Running tests for companyAnnotatedAllRelationshipsFCConcrete.conf with datastoreidentity on 'derby' mapping= ... FAIL
*> Running tests for companyAnnotatedAllRelationshipsFCPM.conf with datastoreidentity on 'derby' mapping= ... FAIL
*> Running tests for companyAnnotatedAllRelationshipsPCConcrete.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsJPAConcrete.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsJPAPM.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsPCPM.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsPIPM.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedEmbeddedFCPM.conf with datastoreidentity on 'derby' mapping= ... FAIL
*> Running tests for companyAnnotatedM-MRelationshipsFCConcrete.conf with datastoreidentity on 'derby' mapping= ... FAIL
*> Running tests for companyAnnotatedM-MRelationshipsFCPM.conf with datastoreidentity on 'derby' mapping= ... FAIL
*> Running tests for companyAnnotatedNoRelationshipsFCConcrete.conf with datastoreidentity on 'derby' mapping= ... FAIL
*> Running tests for companyAnnotatedNoRelationshipsFCPM.conf with datastoreidentity on 'derby' mapping= ... FAIL
*> Running tests for companyAnnotatedNoRelationshipsPCConcrete.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedEmbeddedJPAConcrete.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedEmbeddedJPAPM.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedNoRelationshipsPCPM.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedNoRelationshipsPIPM.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for companyOverrideAnnotatedAllRelationshipsFCPM.conf with datastoreidentity on 'derby' mapping=11 ... FAIL
*> Running tests for inheritance1.conf with datastoreidentity on 'derby' mapping=1 ... success
*> Running tests for inheritance2.conf with datastoreidentity on 'derby' mapping=2 ... success
*> Running tests for inheritance3.conf with datastoreidentity on 'derby' mapping=3 ... success
*> Running tests for inheritance4.conf with datastoreidentity on 'derby' mapping=4 ... success
*> Running tests for relationshipAllRelationships.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for relationshipNoRelationships.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for schemaAttributeClass.conf with datastoreidentity on 'derby' mapping=7 ... success
*> Running tests for schemaAttributeOrm.conf with datastoreidentity on 'derby' mapping=5 ... success
*> Running tests for schemaAttributePackage.conf with datastoreidentity on 'derby' mapping=6 ... success
*> Running tests for compoundIdentity.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for throwOnUnknownStandardProperties.conf with datastoreidentity on 'derby' mapping= ... success
*> Running tests for instancecallbacks.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for jdohelper.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for pm.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for pmf.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for detach.conf with applicationidentity on 'derby' mapping=8 ... success
*> Running tests for embeddedInheritance.conf with applicationidentity on 'derby' mapping=12 ... success
*> Running tests for enhancement.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for extents.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for fetchplan.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for fetchgroup.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for lifecycle.conf with applicationidentity on 'derby' mapping= ... FAIL
*> Running tests for models.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for models1.conf with applicationidentity on 'derby' mapping=1 ... success
*> Running tests for query.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for jdoql.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for jdoql1.conf with applicationidentity on 'derby' mapping=1 ... success
*> Running tests for transactions.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyNoRelationships.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyEmbedded.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for company1-1Relationships.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for company1-MRelationships.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyM-MRelationships.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAllRelationships.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyMapWithoutJoin.conf with applicationidentity on 'derby' mapping=9 ... success
*> Running tests for companyListWithoutJoin.conf with applicationidentity on 'derby' mapping=10 ... success
*> Running tests for companyPMClass.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyPMInterface.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotated1-1RelationshipsFCPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotated1-MRelationshipsFCPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsFCConcrete.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsFCPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsPCConcrete.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsJPAConcrete.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsJPAPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsPCPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedAllRelationshipsPIPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedEmbeddedFCPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedM-MRelationshipsFCConcrete.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedM-MRelationshipsFCPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedNoRelationshipsFCConcrete.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedNoRelationshipsFCPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedNoRelationshipsPCConcrete.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedEmbeddedJPAConcrete.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedEmbeddedJPAPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedNoRelationshipsPCPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyAnnotatedNoRelationshipsPIPM.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for companyOverrideAnnotatedAllRelationshipsFCPM.conf with applicationidentity on 'derby' mapping=11 ... success
*> Running tests for inheritance1.conf with applicationidentity on 'derby' mapping=1 ... success
*> Running tests for inheritance2.conf with applicationidentity on 'derby' mapping=2 ... success
*> Running tests for inheritance3.conf with applicationidentity on 'derby' mapping=3 ... success
*> Running tests for inheritance4.conf with applicationidentity on 'derby' mapping=4 ... success
*> Running tests for relationshipAllRelationships.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for relationshipNoRelationships.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for schemaAttributeClass.conf with applicationidentity on 'derby' mapping=7 ... success
*> Running tests for schemaAttributeOrm.conf with applicationidentity on 'derby' mapping=5 ... success
*> Running tests for schemaAttributePackage.conf with applicationidentity on 'derby' mapping=6 ... success
*> Running tests for compoundIdentity.conf with applicationidentity on 'derby' mapping= ... success
*> Running tests for throwOnUnknownStandardProperties.conf with applicationidentity on 'derby' mapping= ... success

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

Craig L Russell
Secretary, Apache Software Foundation
clr@apache.org http://db.apache.org/jdo


Re: Issue with enhancement of annotations

Posted by Andy Jefferson <an...@datanucleus.org>.
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)

Re: Issue with enhancement of annotations

Posted by Craig Russell <ap...@gmail.com>.
I experimented with putting the annotations into a different directory that has nothing but annotations.

Even though the annotations are only referenced by their use in persistent classes, the DataNucleus enhancer still wants to enhance them.

[ERROR] Failed to execute goal org.apache.jdo:jdo-exectck:3.2-SNAPSHOT:enhance (default) on project jdo-tck: Execution default of goal org.apache.jdo:jdo-exectck:3.2-SNAPSHOT:enhance failed: Class "org.apache.jdo.tck.pc.compositeAnnotation.DatastoreIdDiscriminatorClassNameInheritanceSuperclass" has been specified with an inheritance strategy of "superclass-table", yet no superclass exists or none exists with its own table! -> [Help 1]

So it looks like we will need to change DataNucleus enhancer in order for these tests to work.

Craig

> On Jul 20, 2017, at 12:03 PM, Craig Russell <ap...@gmail.com> wrote:
> 
> Hi Andy,
> 
> 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.
> 
> 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.
> 
> We could try to remove the annotation classes from the list of classes to enhance, but this would really slow things down by needing to get the class object from the class names even though it isn't really needed for anything else.
> 
> Thanks,
> 
> Craig
> 
>> On Jul 19, 2017, at 5:46 PM, Craig Russell <ap...@gmail.com> wrote:
>> 
>> Hi,
>> 
>> I'm trying to run the tck including this composite annotation:
>> 
>> @Target(ElementType.TYPE)
>> @Retention(RetentionPolicy.RUNTIME)
>> @javax.jdo.annotations.PersistenceCapable(detachable="true", identityType=IdentityType.DATASTORE)
>> @javax.jdo.annotations.DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY")
>> @javax.jdo.annotations.Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, column="DISCRIMINATOR", indexed="true")
>> @javax.jdo.annotations.Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE)
>> 
>> public @interface DatastoreIdDiscriminatorClassNameInheritanceSuperclass { }
>> 
>> When I run the enhancement step, it complains:
>> 
>> Failed to execute goal org.apache.jdo:jdo-exectck:3.2-SNAPSHOT:enhance (default) on project jdo-tck: Execution default of goal org.apache.jdo:jdo-exectck:3.2-SNAPSHOT:enhance failed: Class "org.apache.jdo.tck.pc.companyAnnotatedFC.DatastoreIdDiscriminatorClassNameInheritanceSuperclass" has been specified with an inheritance strategy of "superclass-table", yet no superclass exists or none exists with its own table! -> [Help 1]
>> 
>> It looks like the enhancer is trying to enhance this class, but it should not. An annotation cannot be persistent so it should not be enhanced.
>> 
>> Any ideas?
>> 
>> Thanks,
>> 
>> Craig
>> 
>> Craig L Russell
>> clr@apache.org
>> 
> 
> Craig L Russell
> Secretary, Apache Software Foundation
> clr@apache.org http://db.apache.org/jdo
> 

Craig L Russell
Secretary, Apache Software Foundation
clr@apache.org http://db.apache.org/jdo


Re: Issue with enhancement of annotations

Posted by Craig Russell <ap...@gmail.com>.
Hi Andy,

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.

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.

We could try to remove the annotation classes from the list of classes to enhance, but this would really slow things down by needing to get the class object from the class names even though it isn't really needed for anything else.

Thanks,

Craig

> On Jul 19, 2017, at 5:46 PM, Craig Russell <ap...@gmail.com> wrote:
> 
> Hi,
> 
> I'm trying to run the tck including this composite annotation:
> 
> @Target(ElementType.TYPE)
> @Retention(RetentionPolicy.RUNTIME)
> @javax.jdo.annotations.PersistenceCapable(detachable="true", identityType=IdentityType.DATASTORE)
> @javax.jdo.annotations.DatastoreIdentity(strategy=IdGeneratorStrategy.IDENTITY, column="DATASTORE_IDENTITY")
> @javax.jdo.annotations.Discriminator(strategy=DiscriminatorStrategy.CLASS_NAME, column="DISCRIMINATOR", indexed="true")
> @javax.jdo.annotations.Inheritance(strategy=InheritanceStrategy.SUPERCLASS_TABLE)
> 
> public @interface DatastoreIdDiscriminatorClassNameInheritanceSuperclass { }
> 
> When I run the enhancement step, it complains:
> 
> Failed to execute goal org.apache.jdo:jdo-exectck:3.2-SNAPSHOT:enhance (default) on project jdo-tck: Execution default of goal org.apache.jdo:jdo-exectck:3.2-SNAPSHOT:enhance failed: Class "org.apache.jdo.tck.pc.companyAnnotatedFC.DatastoreIdDiscriminatorClassNameInheritanceSuperclass" has been specified with an inheritance strategy of "superclass-table", yet no superclass exists or none exists with its own table! -> [Help 1]
> 
> It looks like the enhancer is trying to enhance this class, but it should not. An annotation cannot be persistent so it should not be enhanced.
> 
> Any ideas?
> 
> Thanks,
> 
> Craig
> 
> Craig L Russell
> clr@apache.org
> 

Craig L Russell
Secretary, Apache Software Foundation
clr@apache.org http://db.apache.org/jdo