Package com.axelor.db

Class JpaSequence

java.lang.Object
com.axelor.db.JpaSequence

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

    Modifier and Type
    Method
    Description
    static String
    nextValue(jakarta.persistence.EntityManager em, 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.
    static void
    nextValue(jakarta.persistence.EntityManager em, 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.
    static String
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • 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 String nextValue(jakarta.persistence.EntityManager em, 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:
      em - the entity manager
      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
    • nextValue

      public static void nextValue(jakarta.persistence.EntityManager em, 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:
      em - the entity manager
      name - the name of the sequence
      next - the next sequence number