Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

JPA LIKE condition

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am using Java 8 with JPA (and Hibernate 5.2.1)  for my ORM.

I am trying to add a LIKE clause to my criteria, but it is still returning the full result set (no errors) without applying the LIKE filter as I would expect.  Please can someone recomment the best way for me to implement this?

Thanks



My output is as follows (as you can see there is a LIKE clause, but perhaps the parameters are incorrect):

10:46:11,706 INFO  [stdout] (default task-2) Hibernate:
10:46:11,707 INFO  [stdout] (default task-2)     select
10:46:11,707 INFO  [stdout] (default task-2)         employee0_.id as id1_1_,
10:46:11,707 INFO  [stdout] (default task-2)         employee0_.AVATAR as AVATAR2_1_,
10:46:11,707 INFO  [stdout] (default task-2)         employee0_.AVERAGE_RATING as AVERAGE_3_1_,
10:46:11,707 INFO  [stdout] (default task-2)         employee0_.DISTANCE as DISTANCE4_1_,
10:46:11,707 INFO  [stdout] (default task-2)         employee0_.DRIVERS_LICENCE as DRIVERS_5_1_,
10:46:11,708 INFO  [stdout] (default task-2)         employee0_.EMAIL_ADDRESS as EMAIL_AD6_1_,
10:46:11,708 INFO  [stdout] (default task-2)         employee0_.FIRST_NAME as FIRST_NA7_1_,
10:46:11,708 INFO  [stdout] (default task-2)         employee0_.JOB_DESCRIPTION as JOB_DESC8_1_,
10:46:11,708 INFO  [stdout] (default task-2)         employee0_.JOB_DETAILS as JOB_DETA9_1_,
10:46:11,708 INFO  [stdout] (default task-2)         employee0_.JOB_TITLE as JOB_TIT10_1_,
10:46:11,708 INFO  [stdout] (default task-2)         employee0_.JOINING_DATE as JOINING11_1_,
10:46:11,708 INFO  [stdout] (default task-2)         employee0_.LASTACCESS_DATE as LASTACC12_1_,
10:46:11,708 INFO  [stdout] (default task-2)         employee0_.LAST_NAME as LAST_NA13_1_,
10:46:11,709 INFO  [stdout] (default task-2)         employee0_.MOBILE_NUMBER as MOBILE_14_1_,
10:46:11,709 INFO  [stdout] (default task-2)         employee0_.PASSWORD as PASSWOR15_1_,
10:46:11,709 INFO  [stdout] (default task-2)         employee0_.PHONE_NUMBER as PHONE_N16_1_,
10:46:11,709 INFO  [stdout] (default task-2)         employee0_.SALARY as SALARY17_1_,
10:46:11,709 INFO  [stdout] (default task-2)         employee0_.SALARY_TIMEFRAME as SALARY_18_1_,
10:46:11,709 INFO  [stdout] (default task-2)         employee0_.SEX as SEX19_1_,
10:46:11,709 INFO  [stdout] (default task-2)         employee0_.USERNAME as USERNAM20_1_,
10:46:11,709 INFO  [stdout] (default task-2)         employee0_.WORK_LAT1 as WORK_LA21_1_,
10:46:11,709 INFO  [stdout] (default task-2)         employee0_.WORK_LAT2 as WORK_LA22_1_,
10:46:11,710 INFO  [stdout] (default task-2)         employee0_.WORK_LAT3 as WORK_LA23_1_,
10:46:11,710 INFO  [stdout] (default task-2)         employee0_.WORK_LAT4 as WORK_LA24_1_,
10:46:11,710 INFO  [stdout] (default task-2)         employee0_.WORK_LAT5 as WORK_LA25_1_,
10:46:11,710 INFO  [stdout] (default task-2)         employee0_.WORK_LONG1 as WORK_LO26_1_,
10:46:11,710 INFO  [stdout] (default task-2)         employee0_.WORK_LONG2 as WORK_LO27_1_,
10:46:11,710 INFO  [stdout] (default task-2)         employee0_.WORK_LONG3 as WORK_LO28_1_,
10:46:11,710 INFO  [stdout] (default task-2)         employee0_.WORK_LONG4 as WORK_LO29_1_,
10:46:11,710 INFO  [stdout] (default task-2)         employee0_.WORK_LONG5 as WORK_LO30_1_
10:46:11,711 INFO  [stdout] (default task-2)     from
10:46:11,711 INFO  [stdout] (default task-2)         employee employee0_
10:46:11,711 INFO  [stdout] (default task-2)     where
10:46:11,711 INFO  [stdout] (default task-2)         employee0_.FIRST_NAME like ?
 
Creator of Enthuware JWS+ V6
Posts: 3390
311
Android Eclipse IDE Chrome
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried without the Predicate?

 
RichardH Marais
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Frits,

thanks for the reply.

Funny thing, I have not changed my code, and it started working.  I think the server was not getting the rebuilt project or something. So the code above works.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

RichardH Marais wrote:Funny thing, I have not changed my code, and it started working.


Ah, the automagically self-solving bug/issue! Definitely my favourite kind
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic