Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

How to createCriteria using joins?

 
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;

}
 
author and cow tipper
Posts: 5000
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
 
Quick! Before anybody notices! Cover it up with this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic