Hibernate named parameters

String query = “select max(r.version) from Relationship r where r.target=:id and r.type=:type”;

TypedQuery<Integer> typedQuery = em.createQuery(query, Integer.class);

typedQuery.setParameter(“id”, target);

typedQuery.setParameter(“type”, type);

Integer result = typedQuery.getSingleResult();

if (result == null) {


result = Integer.valueOf(0);

}

https://www.mkyong.com/hibernate/hibernate-parameter-binding-examples/