I use Hibernate Query with outer joins but its created errors the query here.......
there errors track here
java.lang.RuntimeException: org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! [select P.peopleId,P.firstName,P.surname,P.position,Ptt.title from com.itcentrix.altcp.People.People as P LEFT OUTER JOIN PplTitle as Ptt]
Caused by: org.hibernate.hql.ast.QuerySyntaxException: Path expected for join! [select P.peopleId,P.firstName,P.surname,P.position,Ptt.title from com.itcentrix.altcp.People.People as P LEFT OUTER JOIN PplTitle as Ptt]
... 1 more
HQL cannot translate this query because it does not know how to get from People to PplTitle. In SQL you provide an "ON" clause for your joins, which in HQL must be done via property access. So if your People entity has a "PplTitle title" field, your query would be "... from People as P left outer join P.title as Ptt." You have to tell hibernate how to join the objects.
In People tables Fk of people_title tables......and i define it simple in People class and people HBM not define any relations ships.
can we do this with out relationships?
or i define many to one relation ships.........
Joined: Jun 28, 2008
There are a few problems with the way things have been done.
1) According to your mappings, PplTitles is the parent table and People is the child table.(because your PplTitle contains a Set of People). You have enabled mapping from PplTitle to People but you also need to have the mapping in People hbm for relationship with PplTitle. This is because the actual foreign key in contained in the People table and (as far as i know) it should have a many to one relationship from People to PeopleTitle.
2) your Query should have been
select P.peopleId, Ptt.titleId from PplTitle as Ptt LEFT OUTER JOIN Ptt.peoples as P
select P.peopleId,P.firstName,P.surname,P.position,Ptt.title from People as P LEFT OUTER JOIN PplTitle as Ptt
Notice there are two main changes....
first of all, you should give " LEFT OUTER JOIN Ptt.peoples". (The error Path expected was coming because of it)
secondly, the Left Outer Join should be done from the Parent table to the child table(PplTitle to People) and not from Child Table to Parent Table.
I created the small hibernate setup with your configuration(modified hbms and POJOs) and was able to get the correct results by making the below changes.
1) Modifying the query as mentioned above.
2) adding the following in the People hbm
3) Adding the corresponding PplTitle Field named titles in the People Pojo and putting appropriate getter and setter for it.
PS. I doubt whether PplTitle is the parent table for People but the association mapping that suggests PplTitle contains a Set of People suggests so..
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com