我試圖寫:如何在HQL語言中編寫SQL查詢?
select s.to_date 'Fecha Fin', concat(e.first_name, " ", e.last_name) as 'Full Name', t.title as 'Title', s.salary as 'Salary'
from dept_emp as d
join employees as e on d.emp_no = e.emp_no
join salaries s on s.emp_no = e.emp_no
join titles t on t.emp_no = e.emp_no
where d.dept_no = "d007"
order by e.emp_no, s.to_date desc;
的HQL語言。這是我寫的:
session.createQuery("select s.to_date, concat(e.first_name,'', e.last_name) as FullName, t.title as Title, s.salary as Salary
from Department as d
inner join Employees as e where d.emp_no = e.emp_no
inner join Salaries s where s.emp_no = e.emp_no
inner join Titles t where t.emp_no = e.emp_no
where s.to_date = '9999-01-01'
AND d.dept_no = 'd007'
order by e.emp_no, s.to_date desc") as Department
,但我有此錯誤:
0 [main] ERROR org.hibernate.hql.PARSER - line 10:57: unexpected token: inner
我知道,語法錯誤不是唯一的錯誤,但我無法找到這個問題的任何回答。
有什麼想法? 謝謝。
也許是因爲您在工資和職位後忘記了關鍵字'as' –
謝謝!但事實並非如此..我想這個「as」可以在HQL中消除......我證明了這一點,錯誤仍然存在。 –
然後ist必須是''as'在'部門中作爲d' ;-)自從使用hibernate以來已經很長時間了。我記得有一個'as'的問題。但我不知道到底在哪裏。 –