Google News
logo
JPA - Interview Questions
For persistent fields of type collection, how do you specify if the collection elements have to be loaded eagerly or lazily?
The javax.persistence.ElementCollection has an attribute fetch which can be specified with two values either 'LAZY' or 'EAGER'
 
//Load order lines eagerly
@Entity
public class Order {
 @ElementCollection(fetch=EAGER)
 protected List orderLines = new ArrayList<>();
}

 

Advertisement