Question: The [Hibernate documentation](http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch05.html) gives some information at @BatchSize as :

> 
> @BatchSize specifies a "batch size" for fetching instances of this
>  class by identifier. Not yet loaded instances are loaded batch-size at
>  a time (default 1).
> 
> 
> 

I am not clear on what is the purpose of this annotation, when we need to use this. Can some please help me in understanding when to use this annotation.

Answer: 
Using batch fetching, Hibernate can load several uninitialized proxies if one proxy is accessed. Batch fetching is an optimization of the lazy select fetching strategy. There are two ways you can configure batch fetching: on the class level and the collection level.

Batch fetching for classes/entities is easier to understand. Consider the following example: at runtime you have 25 Cat instances loaded in a Session, and each Cat has a reference to its owner, a Person. The Person class is mapped with a proxy, lazy="true". If you now iterate through all cats and call getOwner() on each, Hibernate will, by default, execute 25 SELECT statements to retrieve the proxied owners. You can tune this behavior by specifying a batch-size in the mapping of Person:

```
<class name="Person" batch-size="10">...</class>

```

Hibernate will now execute only three queries: the pattern is 10, 10, 5.
@BatchSize will fetch record from db based on your size. Think you have 100 records in your result and if you are defined batch size as 10 then it will fetch 10 records per db call. Logically it will increase performance.