• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Quering on multiple tables using criteria api

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a contact entity which have a collection of communication



I want to search on firstName, middleName, and value(in communication)

I tried this:


when i m executing this code i always get size of results 0

What wrong i am doing ??
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm wondering if you need the contact. part?

For example, if I wanted to use a Restriction query on the following entity:



I wouldn't say user.id in my restruction, but just id"



The key part is this line:



A Simple Tutorial on Using the Hibernate Criteria API for Multiple Tables


Since the core class you are doing the restriction with is the contact class, I'm wondering if using the 'contact.' in front of your properties is causing a problem?

Regardless, start small. See if you can get it to work without any restriction. Get one filter field working, and then integrate the other two.

-Cameron McKenzie>
 
Nrapendra Sharma
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i tried without contact. part its the same.
When i am adding restrictions on same table fields i.e firstName and middleName i am getting correct results.
As soon as i add restrictions on communication table i am getting 0 results.

I searched on google and found that i must use Disjunction beacause i need or operator in query.
this is the code


executing this i am getting results but i now getting duplicate records..
Any idea why ??
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic