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

From Eclipsepedia

Jump to: navigation, search
(Issue Summary)
m (General Solution)
 
(8 intermediate revisions by one user not shown)
Line 9: Line 9:
 
==General Solution==
 
==General Solution==
  
WIP
+
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.
  
Our Entity Processing code must now process the entire entity as access type can be changed on a per property basis.  The default and inheritance rules have not changed however and our current implementation can remain. The only exception to this rule is that 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). So that will require a minor change to our current processing logic.
+
A quick break down of the processing logic to determine the access type is as follows:
  
A quick break down of the processing would then look as follows:
+
===Entity access type:===
  
Entity processing:
+
# Check for an explicit access type setting in XML on the entity
 +
# Check for an explicit access type setting on the entity class
 +
# Check the parents access type of an inheritance hierarchy (ignoring those parents with an explicit access type)
 +
## Note: Inheritance hierarchies are processed top down
 +
# Check the location of annotations on the mapped superclasses (ignoring those mapped superclasses with an explicit access type)
 +
# Check the location of annotations on the entity class itself
 +
# Check for an xml default from a persistence-unit-metadata-defaults or entity-mappings setting.
 +
# Search has been exhausted, EclipseLink will default to FIELD.
 +
 
 +
===Embeddable access type:===
 +
 
 +
# Check for an explicit access type setting in XML on the embeddable
 +
# Check for an explicit access type setting on the embeddable class
 +
# Inherits the default access type from the owning entity (as defined from steps 3-7 in Entity access type above).
 +
 
 +
===Mapped superclass access:===
 +
 
 +
# Check for an explicit access type setting in XML on the embeddable
 +
# Check for an explicit access type setting on the embeddable class
 +
# Inherits the default access type from the owning entity (as defined from steps 3-7 in Entity access type above).
 +
 
 +
===Id class access:===
 +
# Inherits the default access type from the owning entity (as defined from steps 3-7 in Entity access type above).
 +
 
 +
Processing of class accessors (entity, embeddable, mapped superclasses) is the as follows:
  
# Determine the access type as we previously did taking into the consideration the entity @Access type mentioned above.
 
## An XML access setting on an entity will override an @Access specification on that same entity or a mapped superclass.
 
## If no access is specified, the entity will then be determined by an entity-mappings access specification, followed by a default-metadata access specification, followed by the default to where annotations are defined on the class.
 
 
# Process the accessors accordingly (and as we currently do)
 
# Process the accessors accordingly (and as we currently do)
# New processing step, process the inverse access type accessors. That is,
+
# New processing step, process the inverse access type accessors if an explicit access type has been specified.
 
## If the access type is FIELD, process those properties that explicitly define Access(PROPERTY), ignore all others.
 
## If the access type is FIELD, process those properties that explicitly define Access(PROPERTY), ignore all others.
 
## If the access type is PROPERTY, process those fields that explicitly define Access(FIELD), ignore all others.
 
## If the access type is PROPERTY, process those fields that explicitly define Access(FIELD), ignore all others.
Line 28: Line 49:
 
## An Access(PROPERTY) is found on a field.
 
## An Access(PROPERTY) is found on a field.
  
Embeddable processing:
+
===Other notes:===
 
+
# Encountered during the entity processing and will continue to inherit it's access type from the owning entity. The exception case now being if the @Embeddable defines an access type.
+
# Processing of the embedable accessors will follow the processing logic defined for an entity.
+
 
+
Other notes:
+
  
# XML merging (an EclipseLink internal functionality) remains as implemented. No changes are necessary.
+
# XML merging (EclipseLink extended functionality) remains as implemented. No changes are necessary.
  
 
==Work Required==
 
==Work Required==
Line 41: Line 57:
 
#: approx 2 days
 
#: approx 2 days
 
# Update Processing to process entire table
 
# Update Processing to process entire table
#: approx 3 days
+
#: approx 5 days

Latest revision as of 13:42, 28 October 2008

Contents

[edit] Access Type

JPA 2.0 Root | Enhancement Request

[edit] 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.

[edit] 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:

[edit] 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.

[edit] 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. Inherits the default access type from the owning entity (as defined from steps 3-7 in Entity access type above).

[edit] 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. Inherits the default access type from the owning entity (as defined from steps 3-7 in Entity access type above).

[edit] Id class access:

  1. Inherits the default access type from the owning entity (as defined from steps 3-7 in Entity access type above).

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.

[edit] Other notes:

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

[edit] Work Required

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