There is a good description here.
This occurs when we getting the results from a table that is normally joined.
Select * from CARS;
select * from WHEELS where cars = ?;
With the second query, with lazy instantiation, the second query is run for all results in the first query. So if there are n cars returned from the first query we get 1 select from the CARS table and n selects from the WHEELS table resulting in (n+1) selects.
To work around this in Hibernate we need to
1) Use Fetch.EAGER to get all the values rather than when we need them with Fetch.LAZY
Use HQL "from WHEELS wheels join fetch wheels.cars cars"
"from WHEELS wheels join fetch wheels.cars cars"
3) Use CRITERIA object
Criteria criteria = session.createCriteria(Cars.class); criteria.setFetchMode("cars", FetchMode.EAGER);