Kodo 4.0.0 generated on May 15 2006

kodo.persistence
Class KodoPersistence

java.lang.Object
  extended by javax.persistence.Persistence
      extended by kodo.persistence.KodoPersistence

public class KodoPersistence
extends Persistence

Static helper method for JPA users, including switching between Kodo native and Java Persistence APIs.

Since:
4.0

Field Summary
static String EM_KEY
           
static String EMF_KEY
           
 
Fields inherited from class javax.persistence.Persistence
PERSISTENCE_PROVIDER, providers
 
Constructor Summary
KodoPersistence()
           
 
Method Summary
static KodoEntityManager cast(EntityManager em)
          Return the Kodo facade to the given entity manager.
static KodoEntityManagerFactory cast(EntityManagerFactory emf)
          Return the Kodo facade to the given entity manager factory.
static KodoQuery cast(Query q)
          Return the Kodo facade to the given query.
static void close(Object o)
          Close the given resource.
static KodoEntityManagerFactory createEntityManagerFactory(String jndiLocation, Context context)
          Returns the EntityManagerFactory at the JNDI location specified by jndiLocation in the context context.
static KodoEntityManagerFactory createEntityManagerFactory(String name, String resource)
          Returns a new KodoEntityManagerFactory specified by name in an XML configuration file at the resource location resource.
static KodoEntityManagerFactory createEntityManagerFactory(String name, String resource, Map map)
          Returns a new KodoEntityManagerFactory specified by name in an XML configuration file at the resource location resource, applying the properties specified in map as overrides.
static Object fromKodoObjectId(Object oid)
          Translate from a Kodo identity object to a Persistence one.
static Class fromKodoObjectIdClass(Class oidClass)
          Translate from a Kodo identity class to a native one.
static KodoEntityManager getEntityManager(Object o)
          Return the entity manager for the given object, if one can be determined from just the object alone.
static KodoEntityManagerFactory getEntityManagerFactory()
          Returns the KodoEntityManagerFactory specified by your Kodo defaults.
static KodoEntityManagerFactory getEntityManagerFactory(Map map)
          Returns the KodoEntityManagerFactory specified by your Kodo defaults, using map as overrides.
static kodo.meta.ClassMetaData getMetaData(EntityManager em, Class cls)
          Returns the ClassMetaData associated with the persistent type cls.
static kodo.meta.ClassMetaData getMetaData(EntityManagerFactory emf, Class cls)
          Returns the ClassMetaData associated with the persistent type cls.
static kodo.meta.ClassMetaData getMetaData(Object o)
          Returns the ClassMetaData associated with the persistent object o.
static boolean isManagedType(EntityManager em, Class cls)
          Returns true if the specified class is an entity or embeddable type.
static boolean isManagedType(EntityManagerFactory emf, Class cls)
          Returns true if the specified class is an entity or embeddable type.
static kodo.kernel.Broker toBroker(EntityManager em)
          Return the underlying broker for the given entity manager facade.
static kodo.kernel.BrokerFactory toBrokerFactory(EntityManagerFactory emf)
          Return the underlying broker factory for the given persistence manager factory facade.
static KodoEntityManager toEntityManager(kodo.kernel.Broker broker)
          Return a persistence manager facade to the given broker retaining previously associated persistence context type.
static KodoEntityManagerFactory toEntityManagerFactory(kodo.kernel.BrokerFactory factory)
          Return an entity manager factory facade to the given broker factory.
static Object toKodoObjectId(kodo.meta.ClassMetaData meta, Object oid)
          Translate from a Persistence identity object to a Kodo one.
static Collection toKodoObjectIds(kodo.meta.ClassMetaData meta, Collection oids)
          Return a collection of Kodo oids for the given native oid collection.
static Object[] toKodoObjectIds(kodo.meta.ClassMetaData meta, Object... oids)
          Return an array of Kodo oids for the given native oid array.
 
Methods inherited from class javax.persistence.Persistence
createEntityManagerFactory, createEntityManagerFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EM_KEY

public static final String EM_KEY
See Also:
Constant Field Values

EMF_KEY

public static final String EMF_KEY
See Also:
Constant Field Values
Constructor Detail

KodoPersistence

public KodoPersistence()
Method Detail

toEntityManagerFactory

public static KodoEntityManagerFactory toEntityManagerFactory(kodo.kernel.BrokerFactory factory)
Return an entity manager factory facade to the given broker factory.


toBrokerFactory

public static kodo.kernel.BrokerFactory toBrokerFactory(EntityManagerFactory emf)
Return the underlying broker factory for the given persistence manager factory facade.


toEntityManager

public static KodoEntityManager toEntityManager(kodo.kernel.Broker broker)
Return a persistence manager facade to the given broker retaining previously associated persistence context type.


toBroker

public static kodo.kernel.Broker toBroker(EntityManager em)
Return the underlying broker for the given entity manager facade.


cast

public static KodoEntityManagerFactory cast(EntityManagerFactory emf)
Return the Kodo facade to the given entity manager factory.


cast

public static KodoEntityManager cast(EntityManager em)
Return the Kodo facade to the given entity manager.


cast

public static KodoQuery cast(Query q)
Return the Kodo facade to the given query.


getEntityManagerFactory

public static KodoEntityManagerFactory getEntityManagerFactory()
Returns the KodoEntityManagerFactory specified by your Kodo defaults. This method will return the same logical factory for each invocation.


getEntityManagerFactory

public static KodoEntityManagerFactory getEntityManagerFactory(Map map)
Returns the KodoEntityManagerFactory specified by your Kodo defaults, using map as overrides. This method will return the same logical factory for invocations with the same overrides.


createEntityManagerFactory

public static KodoEntityManagerFactory createEntityManagerFactory(String name,
                                                                  String resource)

Returns a new KodoEntityManagerFactory specified by name in an XML configuration file at the resource location resource. If name is null, uses the first resource found in the specified location, regardless of the name specified in the XML resource or the name of the jar that the resource is contained in. If resource is null, uses the spec-defined META-INF/persistence.xml resource.

This method only resolves KodoEntityManagerFactory instances.


createEntityManagerFactory

public static KodoEntityManagerFactory createEntityManagerFactory(String name,
                                                                  String resource,
                                                                  Map map)

Returns a new KodoEntityManagerFactory specified by name in an XML configuration file at the resource location resource, applying the properties specified in map as overrides. If name is null, uses the first resource found in the specified location, regardless of the name specified in the XML resource or the name of the jar that the resource is contained in. If resource is null, uses the spec-defined META-INF/persistence.xml resource.

This method only resolves KodoEntityManagerFactory instances.


createEntityManagerFactory

public static KodoEntityManagerFactory createEntityManagerFactory(String jndiLocation,
                                                                  Context context)
Returns the EntityManagerFactory at the JNDI location specified by jndiLocation in the context context. If context is null, new InitialContext() will be used.


getEntityManager

public static KodoEntityManager getEntityManager(Object o)
Return the entity manager for the given object, if one can be determined from just the object alone. This method will succeed for instances that are enhanced, that were loaded from the database (rather than being constructed with new), or that were created through KodoEntityManager.createInstance(java.lang.Class).


getMetaData

public static kodo.meta.ClassMetaData getMetaData(Object o)
Returns the ClassMetaData associated with the persistent object o.


getMetaData

public static kodo.meta.ClassMetaData getMetaData(EntityManager em,
                                                  Class cls)
Returns the ClassMetaData associated with the persistent type cls.


getMetaData

public static kodo.meta.ClassMetaData getMetaData(EntityManagerFactory emf,
                                                  Class cls)
Returns the ClassMetaData associated with the persistent type cls.


close

public static void close(Object o)
Close the given resource. The resource can be an extent iterator, query result, large result set relation, or any closeable Kodo component.


isManagedType

public static boolean isManagedType(EntityManager em,
                                    Class cls)
Returns true if the specified class is an entity or embeddable type.


isManagedType

public static boolean isManagedType(EntityManagerFactory emf,
                                    Class cls)
Returns true if the specified class is an entity or embeddable type.


fromKodoObjectId

public static Object fromKodoObjectId(Object oid)
Translate from a Kodo identity object to a Persistence one.


toKodoObjectId

public static Object toKodoObjectId(kodo.meta.ClassMetaData meta,
                                    Object oid)
Translate from a Persistence identity object to a Kodo one.


toKodoObjectIds

public static Object[] toKodoObjectIds(kodo.meta.ClassMetaData meta,
                                       Object... oids)
Return an array of Kodo oids for the given native oid array.


toKodoObjectIds

public static Collection toKodoObjectIds(kodo.meta.ClassMetaData meta,
                                         Collection oids)
Return a collection of Kodo oids for the given native oid collection.


fromKodoObjectIdClass

public static Class fromKodoObjectIdClass(Class oidClass)
Translate from a Kodo identity class to a native one.


Kodo 4.0.0 generated on May 15 2006

Copyright 2001-2006 BEA Systems, Inc. All Rights Reserved.