Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate criterion query with foreign key relation-ship

 
Narsimha Reddy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have search functionality in my application. Search fields are not belongs to main table.Ids are avaible in main table , corresponding values are avalidable in related table.
I tried using Criterion

crit1=Restrictions.like("sector", sectorName);
detachedCriteria.add(crit1);....


Could some help me out ?
 
Jason Ferguson
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you give a bit more information?

First, can you share the object mappings between the two entities/tables?

Second, which type is sectorName? I'm assuming String, but need to know if sectorName is case-sensitive. If not, try using Restrictions.ilike() instead of Restrictions.like().

Jason

Originally posted by Narsimha Reddy:
I have search functionality in my application. Search fields are not belongs to main table.Ids are avaible in main table , corresponding values are avalidable in related table.
I tried using Criterion

crit1=Restrictions.like("sector", sectorName);
detachedCriteria.add(crit1);....


Could some help me out ?
 
Narsimha Reddy
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got solution for my problem.
I used alias for child table
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic