File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes CriteriaBuilder - I need help converting sql statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "CriteriaBuilder - I need help converting sql statement" Watch "CriteriaBuilder - I need help converting sql statement" New topic
Author

CriteriaBuilder - I need help converting sql statement

Brian Storenson
Ranch Hand

Joined: Aug 24, 2013
Posts: 44
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.
Brian Storenson
Ranch Hand

Joined: Aug 24, 2013
Posts: 44
This is supposed to be a good tutorial on JPA Criteria API:
http://www.ibm.com/developerworks/java/library/j-typesafejpa/

I will start reading that now.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CriteriaBuilder - I need help converting sql statement
 
Similar Threads
JPA Criteria API and EmbeddedIDs
Can anyone tell why is this query not valid?
code review: JPA criteria
How to count the number of rows of a JPA 2 CriteriaQuery in a generic JPA DAO?
Searching row in database by a column which is not a primary key