... import org.eclipse.persistence.config.HintValues; import org.eclipse.persistence.config.QueryHints; ... @NamedQuery(name = "findEmployeesByDepartmentId", query = "select o from Employee o where o.department.id = :departmentId"), hints = {@QueryHint(name=QueryHints.REFRESH, value=HintValues.TRUE)}
It could also be set programmatically thru the setHints() method of the Query API. An example would be:
public ListfindEmployeesByDepartmentId(Long departmentId){ Query query = em.createNamedQuery("findEmployeesByDepartmentId"); query.setParameter("departmentId", departmentId); query.setHint(QueryHints.REFRESH, HintValues.TRUE); return query.getResultList(); }
No comments:
Post a Comment