Package org.hibernate
Record Class BatchSize
java.lang.Object
java.lang.Record
org.hibernate.BatchSize
- Record Components:
batchSize
- The batch size
- All Implemented Interfaces:
FindOption
Specify 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
EntityManager.find(Class, Object, FindOption...)
.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the value of thebatchSize
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
BatchSize
public BatchSize(int batchSize) Creates an instance of aBatchSize
record class.- Parameters:
batchSize
- the value for thebatchSize
record component
-
-
Method Details
-
toString
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. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
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 '=='. -
batchSize
public int batchSize()Returns the value of thebatchSize
record component.- Returns:
- the value of the
batchSize
record component
-