Netbeans Code Template Help

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Netbeans Code Template Help

I am trying to create a Java code template to deal with the obnoxious amount of boilerplate code that JPA Criteria Queries require. This is what I have so far:

CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<${Type}> criteriaQuery = criteriaBuilder.createQuery(${Type}.class);
Root<${Type}> root = criteriaQuery.from(${Type}.class);

TypedQuery<${Type}> query = entityManager.createQuery(criteriaQuery);
List<${Type}> result = query.getResultList();

log.debug("Returned {} results", result.size());

I need to improve it by forcing the import of the various classes. Can anyone help?