• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to createCriteria using joins?

 
Barry Van
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Any one help me createCriteria using Joins ...
Please find the given below joins query :

public List getJobseekerWorkExperience(Integer id) {

StringBuffer selectClause = new StringBuffer(
" select jswe.employerName, jswe.employerAddress, jswe.startFrom, jswe.endTo, jswe.visible, jswe.sortOrder, ");
selectClause
.append(" jswel.businessSector, jswel.occupationTitle, jswel.mainActivities, jswe.id ");
StringBuffer fromClause = new StringBuffer(
" from CvoJsWorkExperience as jswe, ");
fromClause.append(" CvoJsWorkExperienceLingual as jswel ");
StringBuffer whereClause = new StringBuffer(
" where jswe.id=jswel.cvoJsWorkExperience and jswe.cvoJobseeker= ");
whereClause.append(id);
StringBuffer orderbyClause = new StringBuffer(
" order by jswe.sortOrder ");

Query q = session.createQuery(selectClause.toString()
+ fromClause.toString() + whereClause.toString()
+ orderbyClause.toString());
List results = q.list();
return results;

}
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, remember, Hibernate is object based. You can show me all the SQL in the world, but if I don't know what your object model is, I can't write one single line of object based criteria code.

Maybe a quick tutorial on using the Hibernate API is what you need. Check out this quick little tutorial:

How to Use the Criteria API to Query the Database.3

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic