Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

CriteriaBuilder - I need help converting sql statement

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
A feeble attempt to tell you about our stuff that makes us money
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic