`

Hibernate: Fetch plan and fetch strategy

 
阅读更多

1. Hibernate default to a lazy fetching plan for all entities and collections. Lazy setting decides the time to fetch related objects.

2. difference between load and get

 

Item item = (Item)session.load(Item.class, new Long(123));// get a proxy for item
Item item = (Item)session.get(Item.class, new Long(123));// get an item entity

 3. When fetch is set to batch-size in lazy load. For the root, we get the proxy. When we tried to retrieve one of the lazy child with the batch size, it will prefetch the children for the batch-size number of  roots already in persistence context.

4. When fetch is set to subselect in lazy load. For the root, we get the proxy. When we tried to retrieve one of the lazy child with the batch size, it will prefetch the children for theall the roots already in persistence context.

5. When fetch is set to join, it will disable lazy loading. It will also use left outer join to fetch all the related children.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics