Package org.datanucleus.api.jakarta
Class DataNucleusHelperJakarta
- java.lang.Object
-
- org.datanucleus.api.jakarta.DataNucleusHelperJakarta
-
public class DataNucleusHelperJakarta extends Object
Helper class for accessing DataNucleus internals from a Jakarta environment. This is a supplement to the wrap() methods on EntityManagerFactory and EntityManager.
-
-
Constructor Summary
Constructors Constructor Description DataNucleusHelperJakarta()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectgetDatastoreIdForEntity(Object obj)Convenience method to allow access to the datastore id of an object when it is using DN Extension "datastore-id".static Object[]getDetachedStateForObject(Object obj)Accessor for the jdoDetachedState field of a detached object.static String[]getDirtyFields(Object obj, jakarta.persistence.EntityManager em)Accessor for the names of the dirty fields of the persistable object.static jakarta.persistence.EntityManagergetEntityManager(Object obj)Accessor for the EntityManager for the supplied (persistable) object.static String[]getLoadedFields(Object obj, jakarta.persistence.EntityManager em)Accessor for the names of the loaded fields of the persistable object.static ObjectgetObjectId(Object obj)static StringgetObjectState(Object obj)Convenience method to return a string of the state of an object.static ObjectgetSurrogateVersionForEntity(Object obj)Convenience method to allow access to the version of an object when it is using DN Extension "surrogate-version".static booleanisDeleted(Object obj)Convenience accessor for whether the object is deleted.static booleanisDetached(Object obj)Convenience accessor for whether the object is detached.static BooleanisFieldDirty(Object obj, String memberName, jakarta.persistence.EntityManager em)Accessor for whether the specified member (field/property) of the passed persistable object is dirty.static BooleanisFieldLoaded(Object obj, String memberName, jakarta.persistence.EntityManager em)Accessor for whether the specified member (field/property) of the passed persistable object is loaded.static booleanisPersistent(Object obj)Convenience accessor for whether the object is persistent.static booleanisTransactional(Object obj)Convenience accessor for whether the object is transactional.static voidmakeFieldDirty(Object obj, String memberName)Convenience method to mark the specified member (field/property) as dirty, when managed.
-
-
-
Method Detail
-
getSurrogateVersionForEntity
public static Object getSurrogateVersionForEntity(Object obj)
Convenience method to allow access to the version of an object when it is using DN Extension "surrogate-version".- Parameters:
obj- The entity object- Returns:
- The (surrogate) version
-
getDatastoreIdForEntity
public static Object getDatastoreIdForEntity(Object obj)
Convenience method to allow access to the datastore id of an object when it is using DN Extension "datastore-id".- Parameters:
obj- The entity object- Returns:
- The datastore id key
-
getEntityManager
public static jakarta.persistence.EntityManager getEntityManager(Object obj)
Accessor for the EntityManager for the supplied (persistable) object. If the object is detached or transient then returns null.- Parameters:
obj- The persistable object- Returns:
- The entity manager for this object
-
isPersistent
public static boolean isPersistent(Object obj)
Convenience accessor for whether the object is persistent.- Parameters:
obj- The object- Returns:
- Whether it is persistent
-
isDeleted
public static boolean isDeleted(Object obj)
Convenience accessor for whether the object is deleted.- Parameters:
obj- The object- Returns:
- Whether it is deleted
-
isDetached
public static boolean isDetached(Object obj)
Convenience accessor for whether the object is detached.- Parameters:
obj- The object- Returns:
- Whether it is persistent
-
isTransactional
public static boolean isTransactional(Object obj)
Convenience accessor for whether the object is transactional.- Parameters:
obj- The object- Returns:
- Whether it is transactional
-
getObjectState
public static String getObjectState(Object obj)
Convenience method to return a string of the state of an object. Will return things like "detached", "persistent", etc- Parameters:
obj- The object- Returns:
- The state
-
getDetachedStateForObject
public static Object[] getDetachedStateForObject(Object obj)
Accessor for the jdoDetachedState field of a detached object. The returned array is made up of :- 0 - the identity of the object
- 1 - the version of the object (upon detach)
- 2 - loadedFields BitSet
- 3 - dirtyFields BitSet
- Parameters:
obj- The detached object- Returns:
- The detached state
-
getDirtyFields
public static String[] getDirtyFields(Object obj, jakarta.persistence.EntityManager em)
Accessor for the names of the dirty fields of the persistable object.- Parameters:
obj- The persistable objectem- The Entity Manager (only required if the object is detached)- Returns:
- Names of the dirty fields
-
getLoadedFields
public static String[] getLoadedFields(Object obj, jakarta.persistence.EntityManager em)
Accessor for the names of the loaded fields of the persistable object.- Parameters:
obj- Persistable objectem- The Entity Manager (only required if the object is detached)- Returns:
- Names of the loaded fields
-
isFieldLoaded
public static Boolean isFieldLoaded(Object obj, String memberName, jakarta.persistence.EntityManager em)
Accessor for whether the specified member (field/property) of the passed persistable object is loaded.- Parameters:
obj- The persistable objectmemberName- Name of the field/propertyem- EntityManager (if the object is detached)- Returns:
- Whether the member is loaded
-
isFieldDirty
public static Boolean isFieldDirty(Object obj, String memberName, jakarta.persistence.EntityManager em)
Accessor for whether the specified member (field/property) of the passed persistable object is dirty.- Parameters:
obj- The persistable objectmemberName- Name of the field/propertyem- EntityManager (if the object is detached)- Returns:
- Whether the member is dirty
-
makeFieldDirty
public static void makeFieldDirty(Object obj, String memberName)
Convenience method to mark the specified member (field/property) as dirty, when managed. Normally,Persistableclasses are able to detect changes made to their fields, however if a reference to an array is given to a method outside the class, and the array is modified, then the persistent instance is not aware of the change. This API allows the application to notify the instance that a change was made to a field.- Parameters:
obj- The persistable objectmemberName- The member to mark as dirty
-
-