CriteriaBuilder - I need help converting sql statement
posted 2 years ago
I am trying to understand how CriteriaBuilder works. I am trying to implement a createPerson() that creates a record for a new person. The method below will be used to check and see if there is 1 or more records that have the same first and last name of the person that I want to add to my database. I want to convert the following sql statement into the Criteria API syntax:
SELECT COUNT( * )
FROM Person p
WHERE UPPER(p.FIRST_NAME) = UPPER('type.firstName') AND UPPER(P.LAST_NAME) = UPPER('type.lastName');
Can you help? I have been looking at the Criteria API, and the JEE tutorial on JPA. Now I am stuck.