Class MappingHelper

java.lang.Object
org.datanucleus.store.rdbms.mapping.MappingHelper

public class MappingHelper extends Object
Helper class for handling mappings.
  • Constructor Details

    • MappingHelper

      private MappingHelper()
  • Method Details

    • 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 Object getObjectForDatastoreIdentity(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, 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 Object getDatastoreIdentityForResultSetRow(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, 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 Object getApplicationIdentityForResultSetRow(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, 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 Object getObjectForApplicationIdentity(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, 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 Object getObjectForAbstractClass(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, 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 Object createSingleFieldIdentity(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, ResultSet rs, int[] resultIndexes, org.datanucleus.metadata.AbstractClassMetaData cmd, Class objectIdClass, 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 Object createObjectIdentityUsingReflection(org.datanucleus.ExecutionContext ec, JavaTypeMapping mapping, ResultSet rs, int[] resultIndexes, org.datanucleus.metadata.AbstractClassMetaData cmd, 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