Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
JPA Hybrid Query Example
private static final String FIND_ASSIGNEE = "SELECT a.assignee FROM Approvals a WHERE = :reqId";
private EntityManager em;
public void test(String reqId) {
//create once and bind
Query query = em.createQuery(FIND_ASSIGNEE);
em.getEntityManagerFactory().addNamedQuery("findAssignee", query);
//use it
String assignee = em.createNamedQuery("findAssignee")
.setParameter("reqId", reqId)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment