Create new query
- Under Project Management > Data Access click the DAO with which you want to perform a database query, e.g. CustomerDAO.java.
- Press Strg + Space and select query: create new query in the following autocomplete window.
Enter an appropriate method name for the generated method, e.g. findAllCustomer.
findAllCustomer() { select * from }
- After the keyword from, enter C, press Strg + Space and select Customer.
- Click Save.
Result:
Queries - JPA-SQL code.
import com.company.test.entities.Customer findAllCustomer() { select * from Customer }
Java - Generated Java code based on JPA Criteria API. The necessary imports are generated based on the query method.
/** * @queryMethod Do not edit, method is generated by editor! */ public List<Customer> findAllCustomer() { EntityManager entityManager = em(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Customer> criteriaQuery = criteriaBuilder.createQuery(Customer.class); Root<Customer> root = criteriaQuery.from(Customer.class); TypedQuery<Customer> query = entityManager.createQuery(criteriaQuery); return query.getResultList(); }
XDEV Software Corp. - One Embarcadero Center, San Francisco, CA 94111, US
Copyright © 2015. XDEV Software Corp. All rights reserved.