Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/Development/JPA2.0/access type"

(General Solution)
(General Solution)
Line 31: Line 31:
 
# Inherit its access type from the owning entity.
 
# Inherit its access type from the owning entity.
 
## What if the owning entity has an explicit access type setting? @Embeddable will look at where the annotations are defined?
 
## What if the owning entity has an explicit access type setting? @Embeddable will look at where the annotations are defined?
## What if the owning entity has an explicit access type setting but is part of an inheritance hierarchy? Go to the next entity of the
+
## What if the owning entity has an explicit access type setting but is part of an inheritance hierarchy? Go to the next entity of the hierarchy that does not define an explicit access type? Followed by the mapped superclasses (location of annotations). Failing all that go to point 1 (location of annotations on the embeddable class)
        hierarchy that does not define an explicit access type? Followed by the mapped superclasses (location of annotations). Failing  
+
        all that execute point 1 (location of annotations on the embeddable class)
+
 
## An finally failing all that, default to FIELD.
 
## An finally failing all that, default to FIELD.
  

Revision as of 08:40, 11 September 2008

Access Type

JPA 2.0 Root | Enhancement Request

Issue Summary

In JPA 2.0 the specification extends the access type configuration. Access Type will be specified at the Entity Level or the Property Level. New annotations have also been added providing configuration in the Java Class along with orm.xml

See JPA 2.0 ED section 2.3 for details.

General Solution

Our Entity Processing code must now process the entire entity if an explicit access type has been specified. Also since inheritance subclasses can now explicitly specify the Access annotation and override the the inherited access type from from the root. (The root being the first parent that defines an inheritance strategy) this will now need to be changed to the first parent of the inheritance hierarchy that does not specify an explicit type. We therefore need to change our processing to ensure inheritance hierarchies are completely processed top->down. Previously we only ensured the root of the inheritance hierarchy had been processed before processing a sub-class of that hierarchy.

A quick break down of the processing logic to determine the access type is as follows:

Entity access type:

  1. Check for an explicit access type setting in XML on the entity
  2. Check for an explicit access type setting on the entity class
  3. Check the parents access type of an inheritance hierarchy (ignoring those parents with an explicit access type)
    1. Note: Inheritance hierarchies are processed top down
  4. Check the location of annotations on the mapped superclasses (ignoring those mapped superclasses with an explicit access type)
  5. Check the location of annotations on the entity class itself
  6. Check for an xml default from a persistence-unit-metadata-defaults or entity-mappings setting.
  7. Search has been exhausted, EclipseLink will default to FIELD.


Embeddable access type:

  1. Check for an explicit access type setting in XML on the embeddable
  2. Check for an explicit access type setting on the embeddable class
  3. Inherit its access type from the owning entity.
    1. What if the owning entity has an explicit access type setting? @Embeddable will look at where the annotations are defined?
    2. What if the owning entity has an explicit access type setting but is part of an inheritance hierarchy? Go to the next entity of the hierarchy that does not define an explicit access type? Followed by the mapped superclasses (location of annotations). Failing all that go to point 1 (location of annotations on the embeddable class)
    3. An finally failing all that, default to FIELD.

Mapped superclass access:

  1. Check for an explicit access type setting in XML on the embeddable
  2. Check for an explicit access type setting on the embeddable class
  3. Inherit its access type from the owning entity.
    1. The same questions that were mentioned about embeddables would apply here.

Id class access:

  1. Inherits its access type from the owning entity.

Processing of class accessors (entity, embeddable, mapped superclasses) is the as follows:

  1. Process the accessors accordingly (and as we currently do)
  2. New processing step, process the inverse access type accessors if an explicit access type has been specified.
    1. If the access type is FIELD, process those properties that explicitly define Access(PROPERTY), ignore all others.
    2. If the access type is PROPERTY, process those fields that explicitly define Access(FIELD), ignore all others.
  3. At all stages of processing an exception will be thrown in the following cases:
    1. An Access(FIELD) is found on a property
    2. An Access(PROPERTY) is found on a field.

Other notes:

  1. XML merging (EclipseLink extended functionality) remains as implemented. No changes are necessary.

Work Required

  1. Develop model for testing access type settings
    approx 2 days
  2. Update Processing to process entire table
    approx 3 days

Back to the top