Package org.hibernate.annotations
Annotation Type BatchSize
-
@Target({TYPE,METHOD,FIELD}) @Retention(RUNTIME) public @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 thewhere
clause, thewhere
clause contains a list of primary keys inside a SQLin
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 SQLselect
.- See Also:
FetchSettings.DEFAULT_BATCH_FETCH_SIZE
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description int
size
The maximum batch size, a strictly positive integer.
-
-
-
Element Detail
-
size
int size
The maximum batch size, a strictly positive integer. Default is defined byFetchSettings.DEFAULT_BATCH_FETCH_SIZE
-
-