Package org.hibernate.annotations
Annotation Interface BatchSize
Specifies a maximum batch size for batch fetching of the annotated
entity or collection.
When batch fetching is enabled, Hibernate is able to fetch multiple
instances of an entity or collection in a single round trip to the
database. Instead of a SQL select
with just one primary key
value in the where
clause, the where
clause contains
a list of primary keys inside a SQL in
condition. The primary
key values to batch fetch are chosen from among the identifiers of
unfetched entity proxies or collection roles associated with the
session.
For example:
@Entity @BatchSize(size = 100) class Product { ... }
will initialize up to 100 unfetched Product
proxies in each
trip to the database.
Similarly:
@OneToMany @BatchSize(size = 5) / Set<Product> getProducts() { ... };
will initialize up to 5 unfetched collections of Product
s in
each SQL select
.
- See Also:
-
Required Element Summary
Required ElementsModifier and TypeRequired ElementDescriptionint
The maximum batch size, a strictly positive integer.
-
Element Details
-
size
int sizeThe maximum batch size, a strictly positive integer. Default is defined byFetchSettings.DEFAULT_BATCH_FETCH_SIZE
-