Package org.datanucleus.api
Interface ApiAdapter
- All Superinterfaces:
Serializable
Adapter to allow the core runtime to expose multiple APIs to clients.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether the API allows deletion of a non-persistent object.boolean
Whether the API allows (re-)persistence of a deleted object.boolean
Whether the API allows reading a field of a deleted object.boolean
Whether the API requires clearing of the fields of an object when it is deleted.default void
Method to set the pk fields of the object from the provided identity.Convenience method to convert the passed NucleusException into an exception for the API.Convenience method to return a datastore exception appropriate for this API.boolean
Method to return the default setting for cascading attach of a fieldboolean
Method to return the default setting for cascading delete of a fieldboolean
Method to return the default setting for cascading detach of a fieldboolean
Method to return the default setting for cascading persist of a fieldboolean
Method to return the default setting for cascading refresh of a fieldboolean
Method to return the default DFG setting for a persistable field.Method to return a set of default properties for the factory (PMF, EMF, etc)Method to return any default location that doesn't need specifying for "mapping-file" in the persistence.xml.boolean
Whether we should add in metadata when using persistent properties and a property is not specified.Method to return the ExecutionContext (if any) associated with the passed object.default Object
getIdForObject
(Object obj) Method to return the object identity for the passed persistable object.getLifeCycleState
(int stateType) Returns the LifeCycleState for the state constant.getName()
Accessor for the name of the API.default String
getObjectState
(Object pc) Accessor for the object state.default StateManager
Accessor for the state manager for the object.Convenience method to return a user exception appropriate for this API when an unexpected exception occurs.default Object
Method to return the object version for the passed persistable object.getXMLMetaDataForClass
(AbstractClassMetaData cmd, String prefix, String indent) default boolean
Accessor for whether the passed object is deleted.default boolean
isDetachable
(Object obj) Method to return if the passed object is detachable using this API.default boolean
isDetached
(Object obj) Accessor for whether the passed object is detached.default boolean
Accessor for whether the passed object is dirty.default boolean
Whether the provided object is currently managed (has an ExecutionContext).boolean
Accessor for whether this member type is default persistent.default boolean
Accessor for whether the passed object is new.default boolean
isPersistable
(Class cls) Utility method to check if the specified class is of a type that can be persisted for this API.default boolean
isPersistable
(Object obj) Method to return if the passed object is persistable using this API.default boolean
isPersistent
(Object obj) Accessor for whether the passed object is persistent.default boolean
isTransactional
(Object obj) Accessor for whether the passed object is transactional.boolean
isValidPrimaryKeyClass
(Class pkClass, AbstractClassMetaData cmd, ClassLoaderResolver clr, int noOfPkFields, MetaDataManager mmgr) Utility to check if a primary-key class is valid.default void
Method to make the member of the persistable object dirty.
-
Method Details
-
getName
String getName()Accessor for the name of the API. JDO, JPA, Jakarta etc- Returns:
- Name of the API
-
isMemberDefaultPersistent
Accessor for whether this member type is default persistent.- Parameters:
type
- Member type- Returns:
- Whether it is by default persistent
-
getXMLMetaDataForClass
-
getDefaultMappingFileLocation
String getDefaultMappingFileLocation()Method to return any default location that doesn't need specifying for "mapping-file" in the persistence.xml. With JPA/Jakarta this is META-INF/orm.xml. With JDO we don't have such a location.- Returns:
- The default location to try for a mapping-file for this API
-
isManaged
Whether the provided object is currently managed (has an ExecutionContext).- Parameters:
pc
- The persistable object- Returns:
- Whether it is managed
-
getStateManager
Accessor for the state manager for the object.- Parameters:
pc
- The object- Returns:
- The StateManager managing this object
-
getExecutionContext
Method to return the ExecutionContext (if any) associated with the passed object. Supports persistable objects, and PersistenceManager.- Parameters:
pc
- The object- Returns:
- The ExecutionContext
-
getLifeCycleState
Returns the LifeCycleState for the state constant.- Parameters:
stateType
- the type as integer- Returns:
- the type as LifeCycleState object
-
isPersistent
Accessor for whether the passed object is persistent.- Parameters:
obj
- The object- Returns:
- Whether it is persistent
-
isNew
Accessor for whether the passed object is new.- Parameters:
obj
- The object- Returns:
- Whether it is new
-
isDirty
Accessor for whether the passed object is dirty.- Parameters:
obj
- The object- Returns:
- Whether it is dirty
-
isDeleted
Accessor for whether the passed object is deleted.- Parameters:
obj
- The object- Returns:
- Whether it is deleted
-
isDetached
Accessor for whether the passed object is detached.- Parameters:
obj
- The object- Returns:
- Whether it is detached
-
isTransactional
Accessor for whether the passed object is transactional.- Parameters:
obj
- The object- Returns:
- Whether it is transactional
-
isPersistable
Method to return if the passed object is persistable using this API.- Parameters:
obj
- The object- Returns:
- Whether it is persistable
-
isPersistable
Utility method to check if the specified class is of a type that can be persisted for this API.- Parameters:
cls
- The class to check- Returns:
- Whether the class is persistable using this API.
-
isDetachable
Method to return if the passed object is detachable using this API.- Parameters:
obj
- The object- Returns:
- Whether it is detachable
-
getObjectState
Accessor for the object state.- Parameters:
pc
- Persistable object- Returns:
- The state ("persistent-clean", "detached-dirty" etc)
-
makeDirty
Method to make the member of the persistable object dirty.- Parameters:
obj
- The objectmember
- Name of the member
-
getIdForObject
Method to return the object identity for the passed persistable object. Returns null if it is not persistable, or has no identity.- Parameters:
obj
- The object- Returns:
- The identity
-
getVersionForObject
Method to return the object version for the passed persistable object. Returns null if it is not persistable, or not versioned.- Parameters:
obj
- The object- Returns:
- The version
-
isValidPrimaryKeyClass
boolean isValidPrimaryKeyClass(Class pkClass, AbstractClassMetaData cmd, ClassLoaderResolver clr, int noOfPkFields, MetaDataManager mmgr) Utility to check if a primary-key class is valid. Will throw a InvalidPrimaryKeyException if it is invalid, otherwise returning true.- 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
-
copyKeyFieldsFromIdToObject
default void copyKeyFieldsFromIdToObject(Object pc, Persistable.ObjectIdFieldConsumer fm, Object id) Method to set the pk fields of the object from the provided identity.- Parameters:
pc
- The persistable objectfm
- ObjectIdFieldConsumerid
- The identity
-
allowPersistOfDeletedObject
boolean allowPersistOfDeletedObject()Whether the API allows (re-)persistence of a deleted object.- Returns:
- Whether you can call persist on a deleted object
-
allowDeleteOfNonPersistentObject
boolean allowDeleteOfNonPersistentObject()Whether the API allows deletion of a non-persistent object.- Returns:
- Whether you can call delete on an object not yet persisted
-
allowReadFieldOfDeletedObject
boolean allowReadFieldOfDeletedObject()Whether the API allows reading a field of a deleted object.- Returns:
- Whether you can read after deleting
-
clearLoadedFlagsOnDeleteObject
boolean clearLoadedFlagsOnDeleteObject()Whether the API requires clearing of the fields of an object when it is deleted.- Returns:
- Whether to clear loaded fields at delete
-
getDefaultCascadePersistForField
boolean getDefaultCascadePersistForField()Method to return the default setting for cascading persist of a field- Returns:
- default persist cascade setting.
-
getDefaultCascadeDeleteForField
boolean getDefaultCascadeDeleteForField()Method to return the default setting for cascading delete of a field- Returns:
- default cascade delete setting.
-
getDefaultCascadeAttachForField
boolean getDefaultCascadeAttachForField()Method to return the default setting for cascading attach of a field- Returns:
- default cascade attach setting.
-
getDefaultCascadeDetachForField
boolean getDefaultCascadeDetachForField()Method to return the default setting for cascading detach of a field- Returns:
- default cascade detach setting.
-
getDefaultCascadeRefreshForField
boolean getDefaultCascadeRefreshForField()Method to return the default setting for cascading refresh of a field- Returns:
- default cascade refresh setting.
-
getDefaultDFGForPersistableField
boolean getDefaultDFGForPersistableField()Method to return the default DFG setting for a persistable field.- Returns:
- DFG default for persistable field
-
getDefaultFactoryProperties
Method to return a set of default properties for the factory (PMF, EMF, etc)- Returns:
- The default properties (if any) for this API
-
getDefaultPersistentPropertyWhenNotSpecified
boolean getDefaultPersistentPropertyWhenNotSpecified()Whether we should add in metadata when using persistent properties and a property is not specified. True means we add in metadata when not explicitly specified. False means if a property is not defined then it is not persistent.- Returns:
- Whether to default it (JDO = false, JPA/Jakarta = true)
-
getApiExceptionForNucleusException
Convenience method to convert the passed NucleusException into an exception for the API.- Parameters:
ne
- The NucleusException- Returns:
- The Api Exception
-
getUserExceptionForException
Convenience method to return a user exception appropriate for this API when an unexpected exception occurs.- Parameters:
msg
- The messagee
- The cause (if any)- Returns:
- The API exception
-
getDataStoreExceptionForException
Convenience method to return a datastore exception appropriate for this API.- Parameters:
msg
- The messagee
- The cause (if any)- Returns:
- The exception
-