org.apache.openjpa.persistence
Class OpenJPAPersistenceUtil

java.lang.Object
  extended by org.apache.openjpa.persistence.OpenJPAPersistenceUtil

public class OpenJPAPersistenceUtil
extends Object


Constructor Summary
OpenJPAPersistenceUtil()
           
 
Method Summary
static Object getIdentifier(Object entity)
          Returns the identifier of the persistent entity.
static Object getIdentifier(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 LoadState isLoaded(Object obj, String attr)
          Determines whether the attribute on the specified object is loaded and is managed by one of the entity managers.
static boolean isManagedBy(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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenJPAPersistenceUtil

public OpenJPAPersistenceUtil()
Method Detail

getIdentifier

public static Object getIdentifier(Object entity)
Returns the identifier of the persistent entity.

Parameters:
entity -
Returns:
The identifier of the entity or null if the entity is not persistent.

getIdentifier

public static Object getIdentifier(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.

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.

isManagedBy

public static boolean isManagedBy(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.

Parameters:
emf - OpenJPAEntityManagerFactory
sm - StateManager
Returns:
true if this state manager is managed by a broker within this persistence unit.

isLoaded

public static LoadState isLoaded(Object obj,
                                 String attr)
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.


Copyright © 2006-2010 Apache Software Foundation. All Rights Reserved.