Record Class BatchSize

java.lang.Object
java.lang.Record
org.hibernate.BatchSize
Record Components:
batchSize - The batch size
All Implemented Interfaces:
FindOption, FindMultipleOption

@Deprecated(since="8.0", forRemoval=true) public record BatchSize(int batchSize) extends Record implements FindMultipleOption
Deprecated, for removal: This API element is subject to removal in a future version.
Specifies a batch size, that is, how many entities should be fetched in each request to the database, for an invocation of Session.findMultiple(Class, List, FindOption...).
  • By default, the batch sizing strategy is determined by the SQL dialect, but
  • if some batchSize>1 is specified as an argument to this method, then that batch size will be used.

If an explicit batch size is set manually, care should be taken to not exceed the capabilities of the underlying database.

The performance impact of setting a batch size depends on whether a SQL array may be used to pass the list of identifiers to the database:

  • for databases which support standard SQL arrays, a smaller batch size might be extremely inefficient compared to a very large batch size or no batching at all, but
  • on the other hand, for databases with no SQL array type, a large batch size results in long SQL statements with many JDBC parameters.
A batch size is considered a hint. This option has no effect on Session.find(Class, Object, FindOption...).
Since:
7.0
See Also:
  • Nested Class Summary

  • Constructor Summary

    Constructors
    Constructor
    Description
    BatchSize(int batchSize)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates an instance of a BatchSize record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the value of the batchSize record component.
    final boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Indicates whether some other object is "equal to" this one.
    final int
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns a hash code value for this object.
    final String
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • BatchSize

      public BatchSize(int batchSize)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates an instance of a BatchSize record class.
      Parameters:
      batchSize - the value for the batchSize record component
  • Method Details

    • toString

      public final String toString()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • batchSize

      public int batchSize()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the value of the batchSize record component.
      Returns:
      the value of the batchSize record component