Community
Participate
Working Groups
Build Identifier: 2.1.1.v20100817-r8050 Given an entity using **property access level** and having methods annotated with `@Override`, the annotation processor fails to generate the metamodel class. Here is the output of a sample project demonstrating the issue: [INFO] diagnostic error: Exception [EclipseLink-7174] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.ValidationException Exception Description: The getter method [method toString] on entity class [class com.acme.Foo] does not have a corresponding setter method defined. An annotation processor threw an uncaught exception. Consult the following stack trace for details. java.lang.RuntimeException: Exception [EclipseLink-7174] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.ValidationException Exception Description: The getter method [method toString] on entity class [class com.acme.Foo] does not have a corresponding setter method defined. at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:373) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:625) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:554) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:699) at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:981) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727) at com.sun.tools.javac.main.Main.compile(Main.java:353) at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:115) at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:261) at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:129) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:107) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:195) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:140) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:314) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:151) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:445) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:168) at org.apache.maven.cli.MavenCli.main(MavenCli.java:132) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352) Caused by: Exception [EclipseLink-7174] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.ValidationException Exception Description: The getter method [method toString] on entity class [class com.acme.Foo] does not have a corresponding setter method defined. at org.eclipse.persistence.exceptions.ValidationException.noCorrespondingSetterMethodDefined(ValidationException.java:1917) at org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataMethod.isValidPersistenceMethod(MetadataMethod.java:243) at org.eclipse.persistence.internal.jpa.metadata.accessors.objects.MetadataMethod.isValidPersistenceMethod(MetadataMethod.java:222) at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.addAccessorMethods(ClassAccessor.java:387) at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.ClassAccessor.addAccessors(ClassAccessor.java:329) at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.preProcessForCanonicalModel(EntityAccessor.java:649) at org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnit.preProcessForCanonicalModel(PersistenceUnit.java:457) at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:364) ... 30 more [ERROR] error on execute: error during compilation [INFO] ------------------------------------------------------------------------ Reproducible: Always Steps to Reproduce: 1. Run `mvn generate-sources` on the attached project.
Created attachment 183262 [details] testcase
There are some workarounds: - use FIELD access level - comment the @Override But these workaround are not really acceptable, at least for me. - I have some cases where I do not want to use field access level - having to comment @Override on my code base is... a pain. Not even mentioning the time I lost on this issue :) Thanks in advance.
Try adding @Transient to the toString() method as another not great workaround. EclipseLink *should* be looking for methods annotated with JPA annotations, not just any annotation. I am upping the severity as well, this breaks metamodel generation with property access pretty badly
(In reply to comment #3) > Try adding @Transient to the toString() method as another not great workaround. > EclipseLink *should* be looking for methods annotated with JPA annotations, not > just any annotation. I am upping the severity as well, this breaks metamodel > generation with property access pretty badly Thank you for the feedback. Actually, I tried using @Transient on the toString() method but it doesn't help, the annotation processor then complains with the following error. [INFO] diagnostic error: Exception [EclipseLink-7153] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.ValidationException Exception Description: Mapping annotations cannot be applied to fields or properties that have a @Transient specified. [method toString] is in violation of this restriction. ... At least, the annotation processor is consistent... Clearly, it is treating any annotation like @Override, @Deprecated, etc as a JPA annotation. And shouldn't.
Created attachment 183469 [details] Proposed changes
Changes have been submitted to the 2.2 stream. Reviewed: Tom Ware Once the 2.1.3 stream opens up, I'll submit the changes there as well.
*** Bug 323672 has been marked as a duplicate of this bug. ***
*** Bug 336599 has been marked as a duplicate of this bug. ***
Changes were submitted to the 2.1.4 stream.
Trunk checkin (2.2) r8525 2.1 branch checkin r9242
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink