Pro JPA 2 by Mike Keith & Merrick Schincariol

Pro JPA 2 by Mike Keith & Merrick Schincariol

Author:Mike Keith & Merrick Schincariol [Keith, Mike & Schincariol, Merrick]
Language: eng
Format: epub
Tags: Computers, Enterprise Applications, General, Programming Languages, Java
ISBN: 9781430249269
Publisher: Apress
Published: 2013-09-25T04:00:00+00:00


Listing 9-2. Employee Search Using Criteria API

@Stateless

public class SearchService {

@PersistenceContext(unitName="EmployeeHR")

EntityManager em;

public List<Employee> findEmployees(String name, String deptName,

String projectName, String city) {

CriteriaBuilder cb = em.getCriteriaBuilder();

CriteriaQuery<Employee> c = cb.createQuery(Employee.class);

Root<Employee> emp = c.from(Employee.class);

c.select(emp);

c.distinct(true);

Join<Employee,Project> project =

emp.join("projects", JoinType.LEFT);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.