This is JPA named query:
Code:
"SELECT e FROM Employee LEFT JOIN FETCH e.dept"
Employee.class
Code:
@Entity
@Table(name = "EMP")
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
public class Employee implements Serializable {
@Id
@Column(name = "EMP_ID")
private Long id;
@JoinColumn(name ............)
@ManyToOne(optional = false, fetch = FetchType.LAZY)
private Department dept;
method that loads employees:
Code:
List<Employee> employees =
(List<Employees>) em.createNamedQuery("Employee.load")
.setHint("org.hibernate.cacheable", "true")
.getResultList();
First call is OK, data comes from DB and dept is inited.
2nd call, data comes from cache and dept is not inited. I see dept is cached but hibernate doesn't bother to get it form cache and set it to employee.
Thank you very much for any help.