RSingh
RSingh

Reputation: 171

difference between @Fetch(FetchMode.SELECT) and fetch = FetchType.LAZY

I want to know why we need to use both @Fetch(FetchMode.SELECT) and fetch = FetchType.LAZY .fetchMode.select itself tells that all association should be loaded as lazy then why another term? `

@OneToMany(fetch = FetchType.LAZY, mappedBy = "stock")
@Cascade(CascadeType.ALL)
@Fetch(FetchMode.SELECT)
@BatchSize(size = 10)
public Set<StockDailyRecord> getStockDailyRecords() {
return this.stockDailyRecords;
}

`

Upvotes: 2

Views: 1412

Answers (1)

Abdelhak
Abdelhak

Reputation: 8387

FetchType.LAZY: refers to when Hibernate will fetch the association and entities.
@Fetch(FetchMode.SELECT): refers to how Hibernate will fetch the association and entities.

Upvotes: 1

Related Questions