org.datanucleus.jdo
Class NucleusJDOHelper

java.lang.Object
  extended by javax.jdo.JDOHelper
      extended by org.datanucleus.jdo.NucleusJDOHelper
All Implemented Interfaces:
javax.jdo.Constants

public class NucleusJDOHelper
extends javax.jdo.JDOHelper

Helper for persistence operations with DataNucleus. Extends JDOHelper so that people can use this class if they wish.


Field Summary
protected static Localiser LOCALISER
          Localisation utility for output messages
 
Fields inherited from interface javax.jdo.Constants
ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME, ELEMENT_INSTANCE_LIFECYCLE_LISTENER, ELEMENT_PERSISTENCE_MANAGER_FACTORY, ELEMENT_PROPERTY, ENHANCER_EXCEPTION, ENHANCER_NO_JDO_ENHANCER_FOUND, ENHANCER_USAGE_ERROR, INSTANCE_LIFECYCLE_LISTENER_ATTRIBUTE_CLASSES, INSTANCE_LIFECYCLE_LISTENER_ATTRIBUTE_LISTENER, JDO_DTD_RESOURCE, JDO_XSD_NS, JDO_XSD_RESOURCE, JDOCONFIG_DTD_RESOURCE, JDOCONFIG_RESOURCE_NAME, JDOCONFIG_XSD_NS, JDOCONFIG_XSD_RESOURCE, JDOQUERY_DTD_RESOURCE, JDOQUERY_XSD_NS, JDOQUERY_XSD_RESOURCE, JTA, NONCONFIGURABLE_PROPERTY_VENDOR_NAME, NONCONFIGURABLE_PROPERTY_VERSION_NUMBER, OPTION_APPLICATION_IDENTITY, OPTION_ARRAY, OPTION_ARRAYLIST, OPTION_BINARY_COMPATIBILITY, OPTION_CHANGE_APPLICATION_IDENTITY, OPTION_DATASTORE_IDENTITY, OPTION_DATASTORE_TIMEOUT, OPTION_GET_DATASTORE_CONNECTION, OPTION_GET_JDBC_CONNECTION, OPTION_LINKEDLIST, OPTION_MAPPING_HETEROGENEOUS_INTERFACE_TYPE, OPTION_MAPPING_HETEROGENEOUS_OBJECT_TYPE, OPTION_MAPPING_JOINED_TABLE_PER_CLASS, OPTION_MAPPING_JOINED_TABLE_PER_CONCRETE_CLASS, OPTION_MAPPING_NON_JOINED_TABLE_PER_CONCRETE_CLASS, OPTION_MAPPING_RELATION_SUBCLASS_TABLE, OPTION_NONDURABLE_IDENTITY, OPTION_NONTRANSACTIONAL_READ, OPTION_NONTRANSACTIONAL_WRITE, OPTION_NULL_COLLECTION, OPTION_OPTIMISTIC, OPTION_PREDIRTY_EVENT, OPTION_QUERY_CANCEL, OPTION_QUERY_SQL, OPTION_RETAIN_VALUES, OPTION_TRANSACTIONAL_TRANSIENT, OPTION_TREEMAP, OPTION_TREESET, OPTION_UNCONSTRAINED_QUERY_VARIABLES, OPTION_VECTOR, OPTION_VERSION_DATETIME, OPTION_VERSION_STATE_IMAGE, ORM_DTD_RESOURCE, ORM_XSD_NS, ORM_XSD_RESOURCE, PMF_ATTRIBUTE_CLASS, PMF_ATTRIBUTE_CONNECTION_DRIVER_NAME, PMF_ATTRIBUTE_CONNECTION_FACTORY_NAME, PMF_ATTRIBUTE_CONNECTION_FACTORY2_NAME, PMF_ATTRIBUTE_CONNECTION_PASSWORD, PMF_ATTRIBUTE_CONNECTION_URL, PMF_ATTRIBUTE_CONNECTION_USER_NAME, PMF_ATTRIBUTE_COPY_ON_ATTACH, PMF_ATTRIBUTE_DATASTORE_READ_TIMEOUT_MILLIS, PMF_ATTRIBUTE_DATASTORE_WRITE_TIMEOUT_MILLIS, PMF_ATTRIBUTE_DETACH_ALL_ON_COMMIT, PMF_ATTRIBUTE_IGNORE_CACHE, PMF_ATTRIBUTE_MAPPING, PMF_ATTRIBUTE_MULTITHREADED, PMF_ATTRIBUTE_NAME, PMF_ATTRIBUTE_NONTRANSACTIONAL_READ, PMF_ATTRIBUTE_NONTRANSACTIONAL_WRITE, PMF_ATTRIBUTE_OPTIMISTIC, PMF_ATTRIBUTE_PERSISTENCE_UNIT_NAME, PMF_ATTRIBUTE_READONLY, PMF_ATTRIBUTE_RESTORE_VALUES, PMF_ATTRIBUTE_RETAIN_VALUES, PMF_ATTRIBUTE_SERVER_TIME_ZONE_ID, PROPERTY_ATTRIBUTE_NAME, PROPERTY_ATTRIBUTE_VALUE, PROPERTY_CONNECTION_DRIVER_NAME, PROPERTY_CONNECTION_FACTORY_NAME, PROPERTY_CONNECTION_FACTORY2_NAME, PROPERTY_CONNECTION_PASSWORD, PROPERTY_CONNECTION_URL, PROPERTY_CONNECTION_USER_NAME, PROPERTY_COPY_ON_ATTACH, PROPERTY_DATASTORE_READ_TIMEOUT_MILLIS, PROPERTY_DATASTORE_WRITE_TIMEOUT_MILLIS, PROPERTY_DETACH_ALL_ON_COMMIT, PROPERTY_ENHANCER_VENDOR_NAME, PROPERTY_ENHANCER_VERSION_NUMBER, PROPERTY_IGNORE_CACHE, PROPERTY_INSTANCE_LIFECYCLE_LISTENER, PROPERTY_MAPPING, PROPERTY_MAPPING_CATALOG, PROPERTY_MAPPING_SCHEMA, PROPERTY_MULTITHREADED, PROPERTY_NAME, PROPERTY_NONTRANSACTIONAL_READ, PROPERTY_NONTRANSACTIONAL_WRITE, PROPERTY_OPTIMISTIC, PROPERTY_PERSISTENCE_MANAGER_FACTORY_CLASS, PROPERTY_PERSISTENCE_UNIT_NAME, PROPERTY_PREFIX_INSTANCE_LIFECYCLE_LISTENER, PROPERTY_READONLY, PROPERTY_RESTORE_VALUES, PROPERTY_RETAIN_VALUES, PROPERTY_SERVER_TIME_ZONE_ID, PROPERTY_SPI_RESOURCE_NAME, PROPERTY_TRANSACTION_ISOLATION_LEVEL, PROPERTY_TRANSACTION_ISOLATION_LEVEL_READ_COMMITTED, PROPERTY_TRANSACTION_ISOLATION_LEVEL_READ_UNCOMMITTED, PROPERTY_TRANSACTION_ISOLATION_LEVEL_REPEATABLE_READ, PROPERTY_TRANSACTION_ISOLATION_LEVEL_SERIALIZABLE, PROPERTY_TRANSACTION_ISOLATION_LEVEL_SNAPSHOT, RESOURCE_LOCAL, SERVICE_LOOKUP_ENHANCER_RESOURCE_NAME, SERVICE_LOOKUP_PMF_RESOURCE_NAME, TX_READ_COMMITTED, TX_READ_UNCOMMITTED, TX_REPEATABLE_READ, TX_SERIALIZABLE, TX_SNAPSHOT
 
Constructor Summary
NucleusJDOHelper()
           
 
Method Summary
static java.lang.String[] getClassesWithMetaData(javax.jdo.PersistenceManagerFactory pmf)
          Accessor for the names of the classes that have MetaData for this PMF.
static java.lang.String[] getDirtyFields(java.lang.Object obj, javax.jdo.PersistenceManager pm)
          Accessor for the names of the dirty fields of the persistable object.
static javax.jdo.JDOException getJDOExceptionForNucleusException(NucleusException jpe)
          Convenience method to convert an exception into a JDO exception.
static javax.jdo.spi.JDOImplHelper getJDOImplHelper()
          Get the JDOImplHelper instance.
static java.lang.String[] getLoadedFields(java.lang.Object obj, javax.jdo.PersistenceManager pm)
          Accessor for the names of the loaded fields of the persistable object.
static ClassMetaData getMetaDataForClass(javax.jdo.PersistenceManagerFactory pmf, java.lang.Class cls)
          Accessor for the MetaData for the specified class
static JDOQueryCache getQueryResultCache(javax.jdo.PersistenceManagerFactory pmf)
          Convenience accessor for the query results cache.
static java.lang.Boolean isDirty(java.lang.Object obj, java.lang.String memberName, javax.jdo.PersistenceManager pm)
          Accessor for whether the specified member (field/property) of the passed persistable object is dirty.
static java.lang.Boolean isLoaded(java.lang.Object obj, java.lang.String memberName, javax.jdo.PersistenceManager pm)
          Accessor for whether the specified member (field/property) of the passed persistable object is loaded.
static void replicate(javax.jdo.PersistenceManagerFactory pmf1, javax.jdo.PersistenceManagerFactory pmf2, java.lang.Class... types)
          Convenience method to replicate objects of particular types from one datastore (managed by PMF1) to a second datastore (managed by PMF2).
static void replicate(javax.jdo.PersistenceManagerFactory pmf1, javax.jdo.PersistenceManagerFactory pmf2, java.lang.Object... oids)
          Convenience method to replicate a group of objects from one datastore (managed by PMF1) to a second datastore (managed by PMF2).
static void replicate(javax.jdo.PersistenceManagerFactory pmf1, javax.jdo.PersistenceManagerFactory pmf2, java.lang.String... classNames)
          Convenience method to replicate objects of particular types from one datastore (managed by PMF1) to a second datastore (managed by PMF2).
 
Methods inherited from class javax.jdo.JDOHelper
getClassNameFromURL, getDefaultDocumentBuilderFactory, getDefaultErrorHandler, getDocumentBuilderFactory, getEnhancer, getEnhancer, getErrorHandler, getInstance, getNamedPMFProperties, getObjectId, getObjectIds, getObjectIds, getObjectState, getPersistenceManager, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPersistenceManagerFactory, getPropertiesFromJdoconfig, getResources, getTransactionalObjectId, getVersion, invokeGetPersistenceManagerFactoryOnImplementation, isDeleted, isDetached, isDirty, isNew, isNullOrBlank, isPersistent, isTransactional, loadPropertiesFromResource, makeDirty, readNamedPMFProperties, readPropertiesFromPMFElementAttributes, readPropertiesFromPMFSubelements
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final Localiser LOCALISER
Localisation utility for output messages

Constructor Detail

NucleusJDOHelper

public NucleusJDOHelper()
Method Detail

getQueryResultCache

public static JDOQueryCache getQueryResultCache(javax.jdo.PersistenceManagerFactory pmf)
Convenience accessor for the query results cache.

Parameters:
pmf - The PMF
Returns:
The Query results cache

replicate

public static void replicate(javax.jdo.PersistenceManagerFactory pmf1,
                             javax.jdo.PersistenceManagerFactory pmf2,
                             java.lang.Object... oids)
Convenience method to replicate a group of objects from one datastore (managed by PMF1) to a second datastore (managed by PMF2).

Parameters:
pmf1 - PersistenceManagerFactory for the source of the objects
pmf2 - PersistenceManagerFactory for the target of the objects
oids - Identities of the objects to replicate

replicate

public static void replicate(javax.jdo.PersistenceManagerFactory pmf1,
                             javax.jdo.PersistenceManagerFactory pmf2,
                             java.lang.Class... types)
Convenience method to replicate objects of particular types from one datastore (managed by PMF1) to a second datastore (managed by PMF2).

Parameters:
pmf1 - PersistenceManagerFactory for the source of the objects
pmf2 - PersistenceManagerFactory for the target of the objects
types - Types of objects to replicate

replicate

public static void replicate(javax.jdo.PersistenceManagerFactory pmf1,
                             javax.jdo.PersistenceManagerFactory pmf2,
                             java.lang.String... classNames)
Convenience method to replicate objects of particular types from one datastore (managed by PMF1) to a second datastore (managed by PMF2).

Parameters:
pmf1 - PersistenceManagerFactory for the source of the objects
pmf2 - PersistenceManagerFactory for the target of the objects
classNames - Names of classes to replicate

getMetaDataForClass

public static ClassMetaData getMetaDataForClass(javax.jdo.PersistenceManagerFactory pmf,
                                                java.lang.Class cls)
Accessor for the MetaData for the specified class

Parameters:
pmf - PersistenceManager factory
cls - The class
Returns:
The MetaData for the class

getClassesWithMetaData

public static java.lang.String[] getClassesWithMetaData(javax.jdo.PersistenceManagerFactory pmf)
Accessor for the names of the classes that have MetaData for this PMF.

Parameters:
pmf - The PMF
Returns:
The class names

getDirtyFields

public static java.lang.String[] getDirtyFields(java.lang.Object obj,
                                                javax.jdo.PersistenceManager pm)
Accessor for the names of the dirty fields of the persistable object.

Parameters:
obj - The persistable object
pm - The Persistence Manager (only required if the object is detached)
Returns:
Names of the dirty fields

getLoadedFields

public static java.lang.String[] getLoadedFields(java.lang.Object obj,
                                                 javax.jdo.PersistenceManager pm)
Accessor for the names of the loaded fields of the persistable object.

Parameters:
obj - Persistable object
pm - The Persistence Manager (only required if the object is detached)
Returns:
Names of the loaded fields

isLoaded

public static java.lang.Boolean isLoaded(java.lang.Object obj,
                                         java.lang.String memberName,
                                         javax.jdo.PersistenceManager pm)
Accessor for whether the specified member (field/property) of the passed persistable object is loaded.

Parameters:
obj - The persistable object
memberName - Name of the field/property
pm - PersistenceManager (if the object is detached)
Returns:
Whether the member is loaded

isDirty

public static java.lang.Boolean isDirty(java.lang.Object obj,
                                        java.lang.String memberName,
                                        javax.jdo.PersistenceManager pm)
Accessor for whether the specified member (field/property) of the passed persistable object is dirty.

Parameters:
obj - The persistable object
memberName - Name of the field/property
pm - PersistenceManager (if the object is detached)
Returns:
Whether the member is dirty

getJDOExceptionForNucleusException

public static javax.jdo.JDOException getJDOExceptionForNucleusException(NucleusException jpe)
Convenience method to convert an exception into a JDO exception. If the incoming exception has a "failed object" then create the new exception with a failed object. Otherwise if the incoming exception has nested exceptions then create this exception with those nested exceptions. Else create this exception with the incoming exception as its nested exception.

Parameters:
jpe - NucleusException
Returns:
The JDOException

getJDOImplHelper

public static javax.jdo.spi.JDOImplHelper getJDOImplHelper()
Get the JDOImplHelper instance. This must be done in a doPrivileged block.

Returns:
The JDOImplHelper.


Copyright © 2011. All Rights Reserved.