java - org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join -
i have problem hql
have 3 tables
1. users (user_id = pk, username)
2. groups (group_id = pk, group_name)
3. usergroups (user_id = fk, group_id = fk)
<hibernate-mapping> <class name="com.model.authrole.usergroups" table="user_groups" catalog="db_realm" optimistic-lock="version"> <composite-id name="id" class="com.model.authrole.usergroupsid"> <key-property name="userid" type="int"> <column name="user_id" /> </key-property> <key-property name="groupid" type="int"> <column name="group_id" /> </key-property> </composite-id> <many-to-one name="groups" class="com.model.authrole.groups" update="false" insert="false" fetch="select"> <column name="group_id" not-null="true" /> </many-to-one> <many-to-one name="users" class="com.model.authrole.users" update="false" insert="false" fetch="select"> <column name="user_id" not-null="true" /> </many-to-one> <property name="aktiv" type="boolean"> <column name="aktiv" not-null="true" /> </property> </class>
i want show username , group_name
error hql
from usergroups ug inner join users u on u.user = ug.user_id inner join groups g on g.group = ug.group_id
and log error
org.hibernate.hql.internal.ast.querysyntaxexception: path expected join! [from com.model.authrole.usergroups ug inner join users u on u.user = ug.user_id inner join groups g on g.group = ug.group_id]
how fix ?
i assume class usergroups
contains object user
, object group
classes
session.createquery("from usergroups ug ug.user = :user , ug.group =:group").setparameter("user", (users)session.get(users.class,user_id)).setparameter("group", (groups)session.get(groups.class,group_id));
Comments
Post a Comment