Class MappingHelper


  • public class MappingHelper
    extends java.lang.Object
    Helper class for handling mappings.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private MappingHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      protected static java.lang.Object createObjectIdentityUsingReflection​(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, java.sql.ResultSet rs, int[] resultIndexes, org.datanucleus.metadata.AbstractClassMetaData cmd, java.lang.Class objectIdClass)
      Create a user-defined id instance and fill the fields using reflection.
      protected static java.lang.Object createSingleFieldIdentity​(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, java.sql.ResultSet rs, int[] resultIndexes, org.datanucleus.metadata.AbstractClassMetaData cmd, java.lang.Class objectIdClass, java.lang.Class pcClass)
      Create a SingleFieldIdentity instance
      static java.lang.Object getApplicationIdentityForResultSetRow​(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, java.sql.ResultSet rs, int[] resultIndexes, org.datanucleus.metadata.AbstractClassMetaData cmd)
      Get the application identity for the persistable instance from the passed result set row.
      static java.lang.Object getDatastoreIdentityForResultSetRow​(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, java.sql.ResultSet rs, int[] resultIndexes, org.datanucleus.metadata.AbstractClassMetaData cmd)
      Get the datastore identity for the persistable object from the passed result set row.
      static int[] getMappingIndices​(int initialPosition, JavaTypeMapping mapping)
      Convenience method to return an array of positions for datastore columns for the supplied mapping and the initial position value.
      protected static java.lang.Object getObjectForAbstractClass​(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, java.sql.ResultSet rs, int[] resultIndexes, org.datanucleus.metadata.AbstractClassMetaData cmd)
      Create an object id instance and fill the fields using reflection
      static java.lang.Object getObjectForApplicationIdentity​(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, java.sql.ResultSet rs, int[] resultIndexes, org.datanucleus.metadata.AbstractClassMetaData cmd)
      Get the persistent object instance for a class using application identity defined by the provided result set columns
      static java.lang.Object getObjectForDatastoreIdentity​(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, java.sql.ResultSet rs, int[] resultIndexes, org.datanucleus.metadata.AbstractClassMetaData cmd)
      Get the persistable object instance for a class using datastore identity defined by result set columns.
      • Methods inherited from class java.lang.Object

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

      • MappingHelper

        private MappingHelper()
    • Method Detail

      • getMappingIndices

        public static int[] getMappingIndices​(int initialPosition,
                                              JavaTypeMapping mapping)
        Convenience method to return an array of positions for datastore columns for the supplied mapping and the initial position value. For example if the mapping has a single datastore column and the initial position is 1 then returns the array {1}.
        Parameters:
        initialPosition - the initialPosition
        mapping - the Mapping
        Returns:
        an array containing indexes for parameters
      • getObjectForDatastoreIdentity

        public static java.lang.Object getObjectForDatastoreIdentity​(org.datanucleus.ExecutionContext ec,
                                                                     JavaTypeMapping mapping,
                                                                     java.sql.ResultSet rs,
                                                                     int[] resultIndexes,
                                                                     org.datanucleus.metadata.AbstractClassMetaData cmd)
        Get the persistable object instance for a class using datastore identity defined by result set columns.
        Parameters:
        ec - ExecutionContext
        mapping - The mapping in which this is returned
        rs - the ResultSet
        resultIndexes - indexes for the result set
        cmd - the AbstractClassMetaData
        Returns:
        the persistable object
      • getDatastoreIdentityForResultSetRow

        public static java.lang.Object getDatastoreIdentityForResultSetRow​(org.datanucleus.ExecutionContext ec,
                                                                           JavaTypeMapping mapping,
                                                                           java.sql.ResultSet rs,
                                                                           int[] resultIndexes,
                                                                           org.datanucleus.metadata.AbstractClassMetaData cmd)
        Get the datastore identity for the persistable object from the passed result set row.
        Parameters:
        ec - ExecutionContext
        mapping - The mapping in which this is returned
        rs - the ResultSet
        resultIndexes - indexes for the result set
        cmd - the AbstractClassMetaData
        Returns:
        the id
      • getApplicationIdentityForResultSetRow

        public static java.lang.Object getApplicationIdentityForResultSetRow​(org.datanucleus.ExecutionContext ec,
                                                                             JavaTypeMapping mapping,
                                                                             java.sql.ResultSet rs,
                                                                             int[] resultIndexes,
                                                                             org.datanucleus.metadata.AbstractClassMetaData cmd)
        Get the application identity for the persistable instance from the passed result set row.
        Parameters:
        ec - ExecutionContext
        mapping - The Java Type mapping for the instance
        rs - the ResultSet
        resultIndexes - indexes of the ResultSet for the PK field(s)
        cmd - the AbstractClassMetaData
        Returns:
        the id
      • getObjectForApplicationIdentity

        public static java.lang.Object getObjectForApplicationIdentity​(org.datanucleus.ExecutionContext ec,
                                                                       JavaTypeMapping mapping,
                                                                       java.sql.ResultSet rs,
                                                                       int[] resultIndexes,
                                                                       org.datanucleus.metadata.AbstractClassMetaData cmd)
        Get the persistent object instance for a class using application identity defined by the provided result set columns
        Parameters:
        ec - ExecutionContext
        mapping - The mapping in which this is returned
        rs - the ResultSet
        resultIndexes - indexes in the result set to retrieve
        cmd - the AbstractClassMetaData
        Returns:
        the persistent object instance
      • getObjectForAbstractClass

        protected static java.lang.Object getObjectForAbstractClass​(org.datanucleus.ExecutionContext ec,
                                                                    JavaTypeMapping mapping,
                                                                    java.sql.ResultSet rs,
                                                                    int[] resultIndexes,
                                                                    org.datanucleus.metadata.AbstractClassMetaData cmd)
        Create an object id instance and fill the fields using reflection
        Parameters:
        ec - ExecutionContext
        mapping - Mapping in which this is returned
        rs - the ResultSet
        resultIndexes - indexes of the result set to use
        cmd - the AbstractClassMetaData
        Returns:
        the id
      • createSingleFieldIdentity

        protected static java.lang.Object createSingleFieldIdentity​(org.datanucleus.ExecutionContext ec,
                                                                    JavaTypeMapping mapping,
                                                                    java.sql.ResultSet rs,
                                                                    int[] resultIndexes,
                                                                    org.datanucleus.metadata.AbstractClassMetaData cmd,
                                                                    java.lang.Class objectIdClass,
                                                                    java.lang.Class pcClass)
        Create a SingleFieldIdentity instance
        Parameters:
        ec - ExecutionContext
        mapping - Mapping in which this is returned
        rs - the ResultSet
        resultIndexes - the result set index(es)
        cmd - the AbstractClassMetaData
        objectIdClass - the object id class
        pcClass - the persistable class
        Returns:
        the id
      • createObjectIdentityUsingReflection

        protected static java.lang.Object createObjectIdentityUsingReflection​(org.datanucleus.ExecutionContext ec,
                                                                              JavaTypeMapping mapping,
                                                                              java.sql.ResultSet rs,
                                                                              int[] resultIndexes,
                                                                              org.datanucleus.metadata.AbstractClassMetaData cmd,
                                                                              java.lang.Class objectIdClass)
        Create a user-defined id instance and fill the fields using reflection.
        Parameters:
        ec - ExecutionContext
        mapping - Mapping in which this is returned
        rs - the ResultSet
        resultIndexes - the result set index(es)
        cmd - the AbstractClassMetaData
        objectIdClass - the object id class
        Returns:
        the id