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, 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_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_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_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_DETACH_ALL_ON_COMMIT, 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_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[] getDetachedObjectDirtyFields(java.lang.Object obj, javax.jdo.PersistenceManager pm)
          Method to return the names of all fields that are currently dirty in the passed detached object.
static java.lang.String[] getDetachedObjectLoadedFields(java.lang.Object obj, javax.jdo.PersistenceManager pm)
          Method to return the names of all fields that are currently loaded in the passed detached 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 ClassMetaData getMetaDataForClass(javax.jdo.PersistenceManagerFactory pmf, java.lang.Class cls)
          Accessor for the MetaData for the specified class
static QueryResultsMetaData getMetaDataForQueryResults(Query query)
          Accessor for the result metadata for a query.
static java.lang.String getObjectStateAsString(java.lang.Object obj)
          Convenience method to return a string of the state of an object.
 
Methods inherited from class javax.jdo.JDOHelper
getClassNameFromURL, getDefaultDocumentBuilderFactory, getDefaultErrorHandler, getDocumentBuilderFactory, 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

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

getMetaDataForQueryResults

public static QueryResultsMetaData getMetaDataForQueryResults(Query query)
Accessor for the result metadata for a query.

Parameters:
query - The query
Returns:
The MetaData for the class
Throws:
NucleusUserException - Thrown if query type is invalid for getting the results metadata

getObjectStateAsString

public static java.lang.String getObjectStateAsString(java.lang.Object obj)
Convenience method to return a string of the state of an object. Will return things like "detached-dirty", "persistent-clean", etc TODO Remove this when JDOHelper has getObjectState() method returning ObjectState enum.

Parameters:
obj - The object
Returns:
The state

getDetachedObjectDirtyFields

public static java.lang.String[] getDetachedObjectDirtyFields(java.lang.Object obj,
                                                              javax.jdo.PersistenceManager pm)
Method to return the names of all fields that are currently dirty in the passed detached object. TODO Try to remove the need for the PM. We currently use it to generate the temporary StateManager

Parameters:
obj - The PersistenceCapable (detached)
pm - PersistenceManager to use
Returns:
Names of the fields that are dirty
Throws:
NucleusUserException - Thrown if the object is not detached

getDetachedObjectLoadedFields

public static java.lang.String[] getDetachedObjectLoadedFields(java.lang.Object obj,
                                                               javax.jdo.PersistenceManager pm)
Method to return the names of all fields that are currently loaded in the passed detached object. TODO Try to remove the need for the PM. We currently use it to generate the temporary StateManager

Parameters:
obj - The PersistenceCapable (detached)
pm - PersistenceManager to use
Returns:
Names of the fields that are loaded
Throws:
NucleusUserException - Thrown if the object is not detached

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 © 2009. All Rights Reserved.