Skip to main content

Notice: This Wiki is now read only and edits are no longer 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/JPA 2.0/persistence utils"

(Design)
Line 50: Line 50:
  
 
== Design ==
 
== Design ==
 +
 +
===PersistenceUnitUtil===
 +
 +
The PersistenceUnitUtil interface will be implemented by our EntityManagerFactoryImpl class.
 +
 +
The logic required by the interface-defined methods will, for the most part, be defined in static methods.  This will allow the logic to be shared by the ProviderUtil implementations.  The following static methods will be added:
 +
 +
* isLoaded(entity, attribute, session) - return null if there is no descriptor for entity, or no mapping for attribute, else delegate to isLoaded(entity, attribute, Mapping)
 +
* isLoaded(entity, attribute, mapping) - if mapping is a LAZY ForeignRefernceMapping, use the indirection policy to determine if it is instantiated, else check the fetch group to see if it is fetched
 +
* isLoaded(entity, session) - return null if there is no descriptor for entity, iterate through the mappings of the entity an call isLoaded(entity, attribute, mapping) on each and return false if any are not loaded
 +
* getIdentifier(entity) - throw an IllegalArgumentException if there is no descriptor for the entity, or if the descriptor does not have CMPPolicy.  Use the CMPPolicy to build an instance of the primaryKey and return it
 +
 +
The following non static methods will be added (to satisfy the interface).  All will call the appropriate static method listed above and supply the session for this factory.
 +
 +
* isLoaded(entity, attribute) - return true if the static method returns true, false if it returns false or null
 +
* isLoaded(entity) - return true if the static method returns true, false if it returns false or null
 +
* getIdentifier(entity)
  
 
== Documentation ==
 
== Documentation ==

Revision as of 11:28, 22 September 2009

JPA 2.0: PersistenceUtil

JPA 2.0 Root | bug 281884

Date Committer(s) Description
June 29, 2009 gyorke Initial feature template

Summary

The JPA 2.0 specification provides two ways of inquiring about the load-state of classes. PersistenceUnitUtil provides a way of querying a single EntityManagerFactory and ProviderUtil provides a way of querying a whole persistence provider. These interfaces to provide a validation mechanism where a requester can inquire about the state of indirection.

Work Estimate

  • PersistenceUnitUtil - 2 days
  • ProviderUtil - 3 days

Functional Requirements

The functional requirements are defined by the specification.

PersistenceUnitUtil has the following methods:

  • isLoaded(entity) - return whether all the eager fields of an entity are loaded
  • isLoaded(entity, attribute) - returh whether the named attribute is loaded on the given entity
  • getIdentifier - get the primary key of the object

ProviderUtil has the following methods

  • isLoadedWithReference(entity, attribute) - return whether the entity has all its eager fields loaded and the given attribute is loaded
  • isLoadedWithoutReference(entity, attribute) - return whether the entity has all its eager fields loaded and the given attribute is loaded do not trigger indirection
  • isLoaded(entity) - return whether the entity has all its eager fields loaded, do not trigger indirection

Existing Feature Impact

Feature Supported Notes

Design

PersistenceUnitUtil

The PersistenceUnitUtil interface will be implemented by our EntityManagerFactoryImpl class.

The logic required by the interface-defined methods will, for the most part, be defined in static methods. This will allow the logic to be shared by the ProviderUtil implementations. The following static methods will be added:

  • isLoaded(entity, attribute, session) - return null if there is no descriptor for entity, or no mapping for attribute, else delegate to isLoaded(entity, attribute, Mapping)
  • isLoaded(entity, attribute, mapping) - if mapping is a LAZY ForeignRefernceMapping, use the indirection policy to determine if it is instantiated, else check the fetch group to see if it is fetched
  • isLoaded(entity, session) - return null if there is no descriptor for entity, iterate through the mappings of the entity an call isLoaded(entity, attribute, mapping) on each and return false if any are not loaded
  • getIdentifier(entity) - throw an IllegalArgumentException if there is no descriptor for the entity, or if the descriptor does not have CMPPolicy. Use the CMPPolicy to build an instance of the primaryKey and return it

The following non static methods will be added (to satisfy the interface). All will call the appropriate static method listed above and supply the session for this factory.

  • isLoaded(entity, attribute) - return true if the static method returns true, false if it returns false or null
  • isLoaded(entity) - return true if the static method returns true, false if it returns false or null
  • getIdentifier(entity)

Documentation

Testing

Open Issues

Back to the top