[ 
https://issues.apache.org/jira/browse/OPENJPA-1613?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12857473#action_12857473
 ] 

Donald Woods commented on OPENJPA-1613:
---------------------------------------

>From sect. 2.3.1 of the JPA 2.0 spec -
...
All such classes in the entity hierarchy whose access type is defaulted in this 
way must be consistent in their placement of annotations on either fields or 
properties, such that a single, consistent default access type applies within 
the hierarchy. Any embeddable classes used by such classes will have the same 
access type as the default access type of the hierarchy unless the Access 
annotation is specified as defined below.

It is an error if a default access type cannot be determined and an access type 
is not explicitly specified by means of annotations or the XML descriptor. The 
behavior of applications that mix the placement of annotations on fields and 
properties within an entity hierarchy without explicitly specifying the Access 
annotation is undefined.

So, in your case, the method is marked as Transient, so it is ignored.  The 
variable is private, which will not be persistance in the 2.0 spec, so it is 
ignored.  Therefore, the above "It is an error if a default access type cannot 
be determined" comes into play here, since the MappedSuperclass doesn't provide 
an explicit AccessType. 

One could argue though, if we should have thrown an exception, instead of 
defaulting to FIELD (which is the old OpenJPA 1.x behavior, as Private 
variables would be persisted.)


> Exception thrown when enhancing a (property access) class that has an 
> abstract @MappedSuperclass with no annotated properties
> -----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-1613
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-1613
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0-beta2, 2.0.0-beta3
>            Reporter: Simon Droscher
>             Fix For: 2.0.1
>
>         Attachments: abstract-subclass.patch
>
>
> If you have a class (using property access) that has an abstract 
> @MappedSuperclass that happens to have no annotated methods, you get the 
> following exception when enhancing:
> org.apache.openjpa.util.MetaDataException: "implicit property access" for 
> class "org.apache.openjpa.persistence.simple.SubclassPerson" is not 
> consistent with "implicit field access" used by its persistent superclass 
> "org.apache.openjpa.persistence.simple.AbstractSuperclass".  All persistent 
> classes in an inheritance hierarchy must use a single implicit field or 
> property based access style or explicitly declare an access style.
> Presumably the enhancer is deciding incorrectly that the superclass is using 
> field access. A workaround is to annotate the superclass with 
> @Access(AccessType.PROPERTY)  so the enhancer doesn't make this assumption, 
> but that is not JPA 1.0 backwards compatible.
> This did not occur in any of the OpenJPA 1.* versions

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

        

Reply via email to