Hi-
I'm using the sample code for caveatemptor-native-061211 to understand the fetching strategy when navigating a one-to-many list association. What I saw was doesn't reconcile with what I expected. Here is what I did. I removed batch-size="10" from "bids" in Item.hbm.xml. Then I wrote code to load an item and get a bids like this:
Code:
ItemDAO itemDAO = daoFactory.getItemDAO();
Item item = itemDAO.findById(1L, false);
List<Bid> bids = item.getBids();
Bid bid = bids.get(1);
log.debug("Bid amount: " + bid.getAmount());
I expected to see a query for loading the bid at index 1. Instead I saw a query loading all bids for the item. Since collections are lazy loaded by default in Hibernate core and without a batch-size property wouldn't there be a separate query each time a bid is accessed? Am I missing anything else? I realize what I see is more efficient but I'd still like to understand it.
thanks,
Rossen