com.ibm.ism.content.psdi.tools

Class MaxSequenceProvider

  • java.lang.Object
    • com.ibm.ism.content.psdi.tools.MaxSequenceProvider


  • public class MaxSequenceProvider
    extends java.lang.Object
    Generates unique ids for columns that require unique numbers. Currently this is only used for sql server. For databases with sequence generators, database sequences are used. Uses entries from maxsequence table to find the next unique id. If an entry is not found in the maxsequence table, an entry is entered with the maximum value of the column from the table column. The maximum value of the generted key is 2147483647. If the system reaches this limit, then it tries to find from the particular table such as PRLINE to see if there are any gaps in the sequence and tries to use the ids from the found gap. This logic kicks in only when the maximum value of 2147483647 is reached during the id generation.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      protected static java.util.HashMap hm
      This object stores the providers with the key being + "_" + .
      protected static java.util.HashMap hmMain
      This object stores the providers with the key being and the value being set of hm key (see above).
      protected static java.util.HashMap tableOrNot
      Hashmap to keep track of maxsequence entries which are not tables
    • Constructor Summary

      Constructors 
      Constructor and Description
      MaxSequenceProvider()
      Constructor sets up the provider to return unique IDs for the given table column.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      long getUniqueID(java.sql.Connection con, java.lang.String tbname, java.lang.String name)
      Returns a uniqueID for a given table and column defined in maxsequence table.
      void init(java.sql.Connection con)
      Calls init with second parameter True, to load all sequences.
      void init(java.sql.Connection conn, boolean loadAll)
      Initializes the sequences.
      • Methods inherited from class java.lang.Object

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

      • hm

        protected static java.util.HashMap hm
        This object stores the providers with the key being + "_" + . The key is uppercased.
      • hmMain

        protected static java.util.HashMap hmMain
        This object stores the providers with the key being and the value being set of hm key (see above).
      • tableOrNot

        protected static java.util.HashMap tableOrNot
        Hashmap to keep track of maxsequence entries which are not tables
    • Constructor Detail

      • MaxSequenceProvider

        public MaxSequenceProvider()
        Constructor sets up the provider to return unique IDs for the given table column.
        Parameters:
        tbname - Name of the table.
        name - Name of the column.
    • Method Detail

      • init

        public void init(java.sql.Connection con)
                  throws java.lang.Exception
        Calls init with second parameter True, to load all sequences.
        Parameters:
        con -
        Throws:
        java.lang.Exception
      • init

        public void init(java.sql.Connection conn,
                         boolean loadAll)
                  throws java.lang.Exception
        Initializes the sequences. Data is read from the maxsequences table and kept in a cache.
        Parameters:
        con - Connection
        loadAll - True will load all sequences. False will load only the sequences used by Maximo metadata tables (maxobject, maxattribute, etc.). See MaximoDD reload.
        Throws:
        java.lang.Exception
      • getUniqueID

        public long getUniqueID(java.sql.Connection con,
                                java.lang.String tbname,
                                java.lang.String name)
                         throws java.lang.Exception
        Returns a uniqueID for a given table and column defined in maxsequence table. The maximum ID returned in 2147483645 ( Integer.MAX_VALUE).
        Parameters:
        con - Database connection
        tbname - Table name
        name - Column name in the associated table (tbname) for which the unique number is generated.
        Returns:
        a guaranteed unique ID, which will be greater than 0.
        Throws:
        java.lang.Exception