By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 745 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

how to convert a query from SQL to HQL(hibernate Query Language)

P: 58
I want to convert the following query from SQL to HQL.
Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.      student.first_name AS student_first_name,
  3.      course.name AS course_name,
  4.      course.id AS course_id,
  5.      admission.admission_no AS admission_admission_no,
  6.      attendance.status AS attendance_status,
  7. case WHEN attendance.status=1 THEN 'P'
  8.             WHEN attendance.status=2 THEN 'A'
  9. End as Status,
  10.     count(course.id) as Periods,
  11.     count(attendance.status) as Total,
  12.      time_table_item.tt_date AS time_table_item_tt_date,
  13.      attendance.student_batch_id AS attendance_student_batch_id
  14. FROM
  15.      public.time_table_item time_table_item 
  16.      INNER JOIN public.attendance attendance ON time_table_item.id = attendance.time_table_item_id
  17.      INNER JOIN public.syllabus_course syllabus_course ON syllabus_course.id = time_table_item.act_syl_course_id
  18.      INNER JOIN public.course course ON syllabus_course.course_id = course.id
  19.      INNER JOIN public.student_batch student_batch ON attendance.student_batch_id = student_batch.id
  20.      INNER JOIN public.admission admission ON student_batch.admission_id = admission.id
  21.      INNER JOIN public.student student ON admission.student_id = student.id
  22.      AND course.id = syllabus_course.course_id
  23. INNER JOIN public.time_table time_table ON time_table_item.time_table_id = time_table.id
  24. where 
  25.     student_batch.batch_id= $P{Batch} and time_table.level_id= $P{Level} and syllabus_course.course_id = $P{Course}   --course.id=9142294     --course.id=9142294 
  26. group by 
  27.     course.id, admission.admission_no,time_table_item.tt_date,attendance.student_batch_id,
  28.     student.first_name,attendance.status,course.name
  29. order by
  30.     course.id, admission.admission_no,time_table_item.tt_date
  31.  
Can i get the corresponding HQL query for this?
Please help
May 30 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 534
Perhaps this publication will put you on the track.

I don't know whether any conversion tools are available, but look at http://www.hibernate.org/ for what's being developed in this area.
Jun 5 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.