It is very simple.. Simply means, lazy - Not Always(When ever you want that time you will get) eager - Always(If you want or don't want is not a problem, always you will get) if you put (fetch = FetchType.LAZY) that means Whenever you trying to get the particular data then, that particular time only it will carry data for you. If you don't try to call then it won't get data. But 'eager' always get the data while initialized. if you need that data or no need that data, it will definitely carry all data for you where you are mentioned as 'eager'. Example: ... @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<StockDailyRecord> getStockDailyRecords() { return this.stockDailyRecords; } ... } in these example (fetch = FetchType.LAZY) works like - when you trying to get that method that time only It will return the child record for you from the db. if you put it as (fetch = FetchType.EAGER) - Then it will always return child record from the db. | 0 |
By: [email protected] On: Fri Oct 09 11:56:27 IST 2015 0 0 0 | 0 |
Are You Satisfied :0Yes0No |