Dear all,
In the context of Hibernate, I met a problem and I hope I might get an answer from java forum as most of you are also good at Hibernate and SQL.
In most cases, we have a join of two tables which have a direct reference (FK -> PK), this makes HQL easy as follows:
Code:
SQL:
SELECT *
FROM employee
INNER JOIN department
ON employee.DepartmentID = department.DepartmentID
HQL:
Code:
select * from Employee as employee inner join employee.department
Now assume that we want to make a join of two tables which have not direct reference, for example,
Code:
SELECT *
FROM employee
INNER JOIN customer
ON employee.Name = customer.Name
HQL:
Code:
select * from Employee as employee inner Customer as customer where employee.Name = customer.Name
The above gives an exception as “org.hibernate.hql.ast.QuerySyntaxException: Path expected for join!”.
Does it mean HQL does not support this kind of join (without FK – PK association)?
Regards.
Pengyou