Class OpenJPAPersistenceUtil
java.lang.Object
org.apache.openjpa.persistence.OpenJPAPersistenceUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Class<T> getClass(OpenJPAEntityManagerFactory emf, Object entity) static ObjectgetIdentifier(Object entity) Returns the identifier of the persistent entity.static ObjectgetIdentifier(OpenJPAEntityManagerFactory emf, Object entity) Get the object identifier for a persistent entity managed by one of the entity managers of the specified entity manager factory.static ObjectgetVersion(OpenJPAEntityManagerFactory emf, Object entity) Get version of a persistent entity managed by one of the entity managers of the specified entity manager factory.static LoadStateDetermines whether the attribute on the specified object is loaded and is managed by one of the entity managers.static booleanisManagedBy(OpenJPAEntityManagerFactory emf, Object entity) Determines whether the specified state manager is managed by an open broker within the persistence unit of the provided EMF instance.static voidload(OpenJPAEntityManagerFactory emf, Object entity) Loads the given entity from it's entity manager if it is managed.static voidload(OpenJPAEntityManagerFactory emf, Object entity, String attributeName) Loads the given entity attribute from it's entity manager if it is managed.
-
Constructor Details
-
OpenJPAPersistenceUtil
public OpenJPAPersistenceUtil()
-
-
Method Details
-
getIdentifier
-
getIdentifier
Get the object identifier for a persistent entity managed by one of the entity managers of the specified entity manager factory.- Returns:
- The identifier of the entity or null if the entity does not have an identifier assigned or is not managed by any of the entity managers of the entity manager factory.
-
getVersion
Get version of a persistent entity managed by one of the entity managers of the specified entity manager factory.- Parameters:
emf- the entity manager factory presumed to contain the given entityentity- the entity whose version is desired- Returns:
- the version of the entity, or null if it does not have a version field or if it was not persisted yet.
-
isManagedBy
Determines whether the specified state manager is managed by an open broker within the persistence unit of the provided EMF instance.- Parameters:
emf- OpenJPAEntityManagerFactoryentity- the entity to check- Returns:
- true if this entity is managed by a broker within this persistence unit.
-
load
Loads the given entity from it's entity manager if it is managed.- Parameters:
emf- the entity manager factory that contains the manager of the entityentity- the entity that must be loaded
-
load
Loads the given entity attribute from it's entity manager if it is managed.- Parameters:
emf- the entity manager factory that contains the manager of the entityentity- the entity whose attribute has to be loadedattributeName- the attribute to be loaded
-
isLoaded
Determines whether the attribute on the specified object is loaded and is managed by one of the entity managers. Use isManagedBy() to determine if an object is managed by a specific entity manager factory.- Returns:
- LoadState.LOADED - if the attribute is loaded. LoadState.NOT_LOADED - if the attribute is not loaded or any EAGER fetch attributes of the entity are not loaded. LoadState.UNKNOWN - if the entity is not managed by this provider or if it does not contain the persistent attribute.
-
getClass
-