Class CorrespondentColumnsMapper


  • public class CorrespondentColumnsMapper
    extends java.lang.Object
    Class to make correspondence between columns in one side of an association to the mapping at the other side. The 2 sides of the association are referred to as "sideA" and "sideB". The JDO metadata allows definition of the correspondence using the <column name="{column-name}" target="{target-name}"/> syntax.

    This means that the column specified on sideA will be mapped to the specified "target" column on sideB. If no target is provided then the first available sideB column is used for the mapping. Where no columns are defined on sideA, then they will be created to match those on sideB. Checks are made for consistency of the sideA data. When there is insufficient ColumnMetaData on sideA then a new ColumnMetaData is added to the column container.

    • Constructor Summary

      Constructors 
      Constructor Description
      CorrespondentColumnsMapper​(org.datanucleus.metadata.ColumnMetaDataContainer columnContainer, Table tableA, org.datanucleus.metadata.ColumnMetaData[] colmds, JavaTypeMapping mappingSideB, boolean updateContainer)
      Constructor.
      CorrespondentColumnsMapper​(org.datanucleus.metadata.ColumnMetaDataContainer columnContainer, Table tableA, JavaTypeMapping mappingSideB, boolean updateContainer)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.datanucleus.metadata.ColumnMetaData getColumnMetaDataByIdentifier​(DatastoreIdentifier name)
      Accessor for the column MetaData in side A that maps to the side B identifier.
      private void putColumn​(DatastoreIdentifier identifier, org.datanucleus.metadata.ColumnMetaData colmd)
      Method to associate a sideB identifier with a sideA ColumnMetaData
      • Methods inherited from class java.lang.Object

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

      • columnMetaDataBySideBIdentifier

        private final java.util.Map<DatastoreIdentifier,​org.datanucleus.metadata.ColumnMetaData> columnMetaDataBySideBIdentifier
        Map of the ColumnMetaData for each column keyed by the sideB identifier name.
      • columnsName

        private final java.lang.String columnsName
    • Constructor Detail

      • CorrespondentColumnsMapper

        public CorrespondentColumnsMapper​(org.datanucleus.metadata.ColumnMetaDataContainer columnContainer,
                                          Table tableA,
                                          org.datanucleus.metadata.ColumnMetaData[] colmds,
                                          JavaTypeMapping mappingSideB,
                                          boolean updateContainer)
        Constructor. Takes the sideB mapping and the side A definition of column metadata and matches them up as defined by the user, and if not defined by the user matches them as best it can. This constructor allows specification of the column metadata array directly, rather than taking what the container has - is used by ColumnCreator where the user has specified multiple columns but only some of them are for this field being mapped.
        Parameters:
        columnContainer - Container of the columns for side A
        tableA - Table on side A
        colmds - MetaData for the columns to be used
        mappingSideB - the mapping in the side B
        updateContainer - Whether to add any missing ColumnMetaData objects to the container
      • CorrespondentColumnsMapper

        public CorrespondentColumnsMapper​(org.datanucleus.metadata.ColumnMetaDataContainer columnContainer,
                                          Table tableA,
                                          JavaTypeMapping mappingSideB,
                                          boolean updateContainer)
        Constructor. Takes the sideB mapping and the side A definition of column metadata and matches them up as defined by the user, and if not defined by the user matches them as best it can.
        Parameters:
        columnContainer - Container of the columns for side A
        tableA - The table on side A
        mappingSideB - the mapping in the side B that we should map to
        updateContainer - Whether to add any missing ColumnMetaData objects to the container
    • Method Detail

      • getColumnMetaDataByIdentifier

        public org.datanucleus.metadata.ColumnMetaData getColumnMetaDataByIdentifier​(DatastoreIdentifier name)
        Accessor for the column MetaData in side A that maps to the side B identifier.
        Parameters:
        name - The side B identifier
        Returns:
        ColumnMetaData in side A that equates to the side B column
      • putColumn

        private void putColumn​(DatastoreIdentifier identifier,
                               org.datanucleus.metadata.ColumnMetaData colmd)
        Method to associate a sideB identifier with a sideA ColumnMetaData
        Parameters:
        identifier - side B identifier
        colmd - side A ColumnMetaData