Package org.datanucleus.api.jdo
Class JDOAdapter
- java.lang.Object
-
- org.datanucleus.api.jdo.JDOAdapter
-
- All Implemented Interfaces:
Serializable,org.datanucleus.api.ApiAdapter
public class JDOAdapter extends Object implements org.datanucleus.api.ApiAdapter
Adapter for the JDO API, to allow the DataNucleus core runtime to expose multiple APIs to clients.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static Set<String>defaultPersistentTypeNames
-
Constructor Summary
Constructors Constructor Description JDOAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowDeleteOfNonPersistentObject()Whether the API allows deletion of a non-persistent object.booleanallowPersistOfDeletedObject()Whether the API allows (re-)persistence of a deleted object.booleanallowReadFieldOfDeletedObject()Whether the API allows reading a field of a deleted object.booleanclearLoadedFlagsOnDeleteObject()Whether the API requires clearing of the fields of an object when it is deleted.RuntimeExceptiongetApiExceptionForNucleusException(org.datanucleus.exceptions.NucleusException ne)RuntimeExceptiongetDataStoreExceptionForException(String msg, Exception e)Convenience method to return a datastore exception appropriate for this API.booleangetDefaultCascadeDeleteForField()booleangetDefaultCascadeDetachForField()booleangetDefaultCascadePersistForField()booleangetDefaultCascadeRefreshForField()booleangetDefaultCascadeUpdateForField()booleangetDefaultDFGForPersistableField()MapgetDefaultFactoryProperties()Method to return the default factory properties for this API.org.datanucleus.ExecutionContextgetExecutionContext(Object obj)Method to return the ExecutionContext (if any) associated with the passed object.org.datanucleus.state.LifeCycleStategetLifeCycleState(int stateType)Returns the LifeCycleState for the state constant.StringgetName()Accessor for the name of the API.StringgetObjectState(Object obj)Accessor for the object state.RuntimeExceptiongetUserExceptionForException(String msg, Exception e)Convenience method to return a user exception appropriate for this API.booleanisMemberDefaultPersistent(Class type)booleanisValidPrimaryKeyClass(Class pkClass, org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.ClassLoaderResolver clr, int noOfPkFields, org.datanucleus.metadata.MetaDataManager mmgr)Utility to check if a primary-key class is valid.
-
-
-
Method Detail
-
getName
public String getName()
Accessor for the name of the API.- Specified by:
getNamein interfaceorg.datanucleus.api.ApiAdapter- Returns:
- Name of the API
-
isMemberDefaultPersistent
public boolean isMemberDefaultPersistent(Class type)
- Specified by:
isMemberDefaultPersistentin interfaceorg.datanucleus.api.ApiAdapter
-
getExecutionContext
public org.datanucleus.ExecutionContext getExecutionContext(Object obj)
Method to return the ExecutionContext (if any) associated with the passed object. Supports persistable objects, and PersistenceManager.- Specified by:
getExecutionContextin interfaceorg.datanucleus.api.ApiAdapter- Parameters:
obj- The object- Returns:
- The ExecutionContext
-
getLifeCycleState
public org.datanucleus.state.LifeCycleState getLifeCycleState(int stateType)
Returns the LifeCycleState for the state constant.- Specified by:
getLifeCycleStatein interfaceorg.datanucleus.api.ApiAdapter- Parameters:
stateType- the type as integer- Returns:
- the type as LifeCycleState object
-
getObjectState
public String getObjectState(Object obj)
Accessor for the object state.- Specified by:
getObjectStatein interfaceorg.datanucleus.api.ApiAdapter- Parameters:
obj- Object- Returns:
- The state ("persistent-clean", "detached-dirty" etc)
-
isValidPrimaryKeyClass
public boolean isValidPrimaryKeyClass(Class pkClass, org.datanucleus.metadata.AbstractClassMetaData cmd, org.datanucleus.ClassLoaderResolver clr, int noOfPkFields, org.datanucleus.metadata.MetaDataManager mmgr)
Utility to check if a primary-key class is valid. Will throw a InvalidPrimaryKeyException if it is invalid, otherwise returning true.- Specified by:
isValidPrimaryKeyClassin interfaceorg.datanucleus.api.ApiAdapter- Parameters:
pkClass- The Primary Key classcmd- AbstractClassMetaData for the persistable classclr- the ClassLoaderResolvernoOfPkFields- Number of primary key fieldsmmgr- MetaData manager- Returns:
- Whether it is valid
-
allowPersistOfDeletedObject
public boolean allowPersistOfDeletedObject()
Whether the API allows (re-)persistence of a deleted object.- Specified by:
allowPersistOfDeletedObjectin interfaceorg.datanucleus.api.ApiAdapter- Returns:
- Whether you can call persist on a deleted object
-
allowDeleteOfNonPersistentObject
public boolean allowDeleteOfNonPersistentObject()
Whether the API allows deletion of a non-persistent object.- Specified by:
allowDeleteOfNonPersistentObjectin interfaceorg.datanucleus.api.ApiAdapter- Returns:
- Whether you can call delete on an object not yet persisted
-
allowReadFieldOfDeletedObject
public boolean allowReadFieldOfDeletedObject()
Whether the API allows reading a field of a deleted object.- Specified by:
allowReadFieldOfDeletedObjectin interfaceorg.datanucleus.api.ApiAdapter- Returns:
- Whether you can read after deleting
-
clearLoadedFlagsOnDeleteObject
public boolean clearLoadedFlagsOnDeleteObject()
Whether the API requires clearing of the fields of an object when it is deleted.- Specified by:
clearLoadedFlagsOnDeleteObjectin interfaceorg.datanucleus.api.ApiAdapter- Returns:
- Whether to clear loaded fields at delete
-
getDefaultCascadePersistForField
public boolean getDefaultCascadePersistForField()
- Specified by:
getDefaultCascadePersistForFieldin interfaceorg.datanucleus.api.ApiAdapter
-
getDefaultCascadeUpdateForField
public boolean getDefaultCascadeUpdateForField()
- Specified by:
getDefaultCascadeUpdateForFieldin interfaceorg.datanucleus.api.ApiAdapter
-
getDefaultCascadeDeleteForField
public boolean getDefaultCascadeDeleteForField()
- Specified by:
getDefaultCascadeDeleteForFieldin interfaceorg.datanucleus.api.ApiAdapter
-
getDefaultCascadeDetachForField
public boolean getDefaultCascadeDetachForField()
- Specified by:
getDefaultCascadeDetachForFieldin interfaceorg.datanucleus.api.ApiAdapter
-
getDefaultCascadeRefreshForField
public boolean getDefaultCascadeRefreshForField()
- Specified by:
getDefaultCascadeRefreshForFieldin interfaceorg.datanucleus.api.ApiAdapter
-
getDefaultDFGForPersistableField
public boolean getDefaultDFGForPersistableField()
- Specified by:
getDefaultDFGForPersistableFieldin interfaceorg.datanucleus.api.ApiAdapter
-
getDefaultFactoryProperties
public Map getDefaultFactoryProperties()
Method to return the default factory properties for this API.- Specified by:
getDefaultFactoryPropertiesin interfaceorg.datanucleus.api.ApiAdapter- Returns:
- The default props
-
getUserExceptionForException
public RuntimeException getUserExceptionForException(String msg, Exception e)
Convenience method to return a user exception appropriate for this API.- Specified by:
getUserExceptionForExceptionin interfaceorg.datanucleus.api.ApiAdapter- Parameters:
msg- The messagee- The cause- Returns:
- The JDO exception
-
getDataStoreExceptionForException
public RuntimeException getDataStoreExceptionForException(String msg, Exception e)
Convenience method to return a datastore exception appropriate for this API.- Specified by:
getDataStoreExceptionForExceptionin interfaceorg.datanucleus.api.ApiAdapter- Parameters:
msg- The messagee- Any root cause exception- Returns:
- The exception
-
getApiExceptionForNucleusException
public RuntimeException getApiExceptionForNucleusException(org.datanucleus.exceptions.NucleusException ne)
- Specified by:
getApiExceptionForNucleusExceptionin interfaceorg.datanucleus.api.ApiAdapter
-
-