Class ApplicationIds


  • public class ApplicationIds
    extends java.lang.Object
    Utility class for manipulating application object ids.
    Author:
    Abe White
    • Constructor Summary

      Constructors 
      Constructor Description
      ApplicationIds()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean assign​(OpenJPAStateManager sm, StoreManager store, boolean preFlush)
      Assign an application identity object to the given state, or return false if determining the application identity requires a flush.
      static java.lang.Object copy​(java.lang.Object oid, ClassMetaData meta)
      Copy the given oid value.
      static java.lang.Object create​(PersistenceCapable pc, ClassMetaData meta)
      Generate an application id based on the current primary key field state of the given instance.
      static java.lang.Object fromPKValues​(java.lang.Object[] pks, ClassMetaData meta)
      Return a new object id constructed from the given primary key values.
      static java.lang.Object get​(java.lang.Object oid, FieldMetaData fmd)
      Return the given primary key field value from the given oid.
      static java.lang.Object getKey​(java.lang.Object id, ClassMetaData meta)
      Return the key from the given id.
      static boolean isIdSet​(java.lang.Object id, ClassMetaData meta, java.lang.String mappedByIdFieldName)
      Check if object id is set or not.
      static void setAppId​(ObjectId id, java.lang.Object newId)
      Sets the underlying id of an ObjectId.
      static java.lang.Object[] toPKValues​(java.lang.Object oid, ClassMetaData meta)
      Return the primary key values for the given object id.
      static java.lang.Object wrap​(ClassMetaData meta, java.lang.Object oid)
      Wraps the given object for the given type into a OpenJPA specific application identity object wrapper instance (i.e.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ApplicationIds

        public ApplicationIds()
    • Method Detail

      • toPKValues

        public static java.lang.Object[] toPKValues​(java.lang.Object oid,
                                                    ClassMetaData meta)
        Return the primary key values for the given object id. The values will be returned in the same order as the metadata primary key fields. Values for PC primary key fields will be the primary key value or oid value of the related instance (depending on FieldMetaData#isObjectIdFieldIdOfPC).
      • wrap

        public static java.lang.Object wrap​(ClassMetaData meta,
                                            java.lang.Object oid)
        Wraps the given object for the given type into a OpenJPA specific application identity object wrapper instance (i.e. ObjectId) if all of the following is true: the given type is not using built-in OpenJPA identity types the given type is using a shared OpenJPA identity type the given object is not already a wrapper identity type
      • fromPKValues

        public static java.lang.Object fromPKValues​(java.lang.Object[] pks,
                                                    ClassMetaData meta)
        Return a new object id constructed from the given primary key values. Values for PC primary key fields should be the primary key value or oid value of the related instance (depending on FieldMetaData#isObjectIdFieldIdOfPC).
      • copy

        public static java.lang.Object copy​(java.lang.Object oid,
                                            ClassMetaData meta)
        Copy the given oid value.
      • get

        public static java.lang.Object get​(java.lang.Object oid,
                                           FieldMetaData fmd)
        Return the given primary key field value from the given oid.
      • create

        public static java.lang.Object create​(PersistenceCapable pc,
                                              ClassMetaData meta)
        Generate an application id based on the current primary key field state of the given instance.
      • assign

        public static boolean assign​(OpenJPAStateManager sm,
                                     StoreManager store,
                                     boolean preFlush)
        Assign an application identity object to the given state, or return false if determining the application identity requires a flush.
      • isIdSet

        public static boolean isIdSet​(java.lang.Object id,
                                      ClassMetaData meta,
                                      java.lang.String mappedByIdFieldName)
        Check if object id is set or not.
      • getKey

        public static java.lang.Object getKey​(java.lang.Object id,
                                              ClassMetaData meta)
        Return the key from the given id.
      • setAppId

        public static void setAppId​(ObjectId id,
                                    java.lang.Object newId)
        Sets the underlying id of an ObjectId. Should only be used with simple (idclass) types.