2012-10-23 97 views
1

我是新來寫HQl查詢請幫助我..其實我的SQL Query是有5個表即COURSESKILLSETTIMETABLEINTRESTUSER如何使用連接編寫Hibernate HQL查詢?

select 
(select count(*) from intrest) AS 
    NoAttends,course.NAME,course.TYPE,user.FIRSTNAME,user.LASTNAME,skill.COURSE_CONT, 
    skill.TEACH_EXP,tt.CLASS_DUR,tt.COURSE_DUR,tt.DATE_TIME from COURSE course 
    inner join SKILLSET skill on 
    skill.course_id=course.s_id 
    inner join USER user on 
    user.s_id=skill.user_id 
    inner join TIMETABLE tt on 
    tt.course_id=course.s_id 
    where course.name IN ('course') 
    ORDER BY course.name LIMIT 10; 

幫我嗎?

回答

1

請試試下面的內容。 。 。 。 。

SELECT t1.col1, t2.col2, t3.col3 
FROM Table1 t1 JOIN t1.someGroupMemebers t2 
JOIN t2.someUser t3 WHERE t3.username = 'blah blah' 
0

使用JPA對Hibernate這是很容易爲前:

entityManager.createQuery("select cd from CourseDetailsVO cd join cd.course.keywords k where k.keyword in (:courseName) and cd.startDate between (:sDate) and (:eDate)", CourseDetailsVO.class); 
setParameter("courseName", searchVO.getName()).. 
... 

的EntityManager會做處理..