Top Description Methods
org.hibernate.annotations

public @Interface BatchSize

extends Annotation
Annotations
@Target:TYPE, METHOD, FIELD
@Retention:RUNTIME
Imports
java.lang.annotation.Retention, .Target

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 Products in each SQL select.

Authors
Emmanuel Bernard, Steve Ebersole
See Also
org.hibernate.cfg.AvailableSettings#DEFAULT_BATCH_FETCH_SIZE

Method Summary

Modifier and TypeMethod and Description
public int
size()

The maximum batch size, a strictly positive integer.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

sizeback to summary
public int size()

The maximum batch size, a strictly positive integer.

Default is defined by org.hibernate.cfg.FetchSettings#DEFAULT_BATCH_FETCH_SIZE