Package com.axelor.db

Class JpaSequence


  • public final class JpaSequence
    extends Object
    This class provides some helper static methods to deal with custom sequences.
    • Method Detail

      • nextValue

        public static String nextValue​(String name)
        Get the next sequence value of the given sequence.

        This method must be called inside a running transaction as it updates the sequence details in database.
        Parameters:
        name - the name of the sequence
        Returns:
        next sequence value
      • nextValue

        public static void nextValue​(String name,
                                     long next)
        Set the next numeric value for the given sequence.

        This method must be called inside a running transaction as it updates the sequence details in the database.

        This method is generally used to reset the sequence. It may cause duplicates if given next number is less then the last next value of the sequence.
        Parameters:
        name - the name of the sequence
        next - the next sequence number