вторник, 28 марта 2017 г.

Hibernate – fetching strategies

Fetching Strategies

There are four fetching strategies
1. fetch-“join” = Disable the lazy loading, always load all the collections and entities.
2. fetch-“select” (default) = Lazy load all the collections and entities.
3. batch-size=”N” = Fetching up to ‘N’ collections or entities, *Not record*.
4. fetch-“subselect” = Group its collection into a sub select statement.
...
@Entity
@Table(name = "stock", catalog = "mkyong")
public class Stock implements Serializable{
...
 @OneToMany(fetch = FetchType.LAZY, mappedBy = "stock")
 @Cascade(CascadeType.ALL)
 @Fetch(FetchMode.SELECT)
        @BatchSize(size = 10)
 public Set getStockDailyRecords() {
  return this.stockDailyRecords;
 }
...
}


http://www.mkyong.com/hibernate/hibernate-fetching-strategies-examples/

Комментариев нет:

Отправить комментарий