Skip to content

Instantly share code, notes, and snippets.

@jdewind
Created August 10, 2012 19:15
Show Gist options
  • Save jdewind/3317018 to your computer and use it in GitHub Desktop.
Save jdewind/3317018 to your computer and use it in GitHub Desktop.
AOP Solution
@RefreshEntity
public List<SchoolBus> findAll() {
CriteriaBuilder criteriaBuilder = getEntityManager().getCriteriaBuilder();
CriteriaQuery<SchoolBus> criteriaQuery = criteriaBuilder.createQuery(SchoolBus.class);
Root<SchoolBus> table = criteriaQuery.from(SchoolBus.class);
TypedQuery<SchoolBus> query = getEntityManager().createQuery(criteriaQuery.select(table).orderBy(criteriaBuilder.asc(table.get("busNumber"))));
return query.getResultList();
}
@RefreshEntity
public SchoolBus findById(Long id) {
SchoolBus schoolBus = getEntityManager().find(SchoolBus.class, id);
return schoolBus;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment