File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate criterion query with foreign key relation-ship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate criterion query with foreign key relation-ship" Watch "Hibernate criterion query with foreign key relation-ship" New topic
Author

Hibernate criterion query with foreign key relation-ship

Narsimha Reddy
Greenhorn

Joined: Jan 08, 2008
Posts: 6
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

Joined: Aug 09, 2007
Posts: 58
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

Joined: Jan 08, 2008
Posts: 6
I got solution for my problem.
I used alias for child table
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate criterion query with foreign key relation-ship
 
Similar Threads
web interface to search database
struts2 + hibernate dynamic search criteria
OJB error
web interface to search database
Implementing GUI