Hello all,
Here is my sql.
A user can have many roles.
<hibernate-mapping> <class name="com.mislbd.iris.marketing.survey.UserDTO" table="TestUser"> <id column="userId" name="id"> <generator class="increment"/> </id> <property name="name"/> <property name="loginId"/> <property name="password"/> <list name="roles" table="TestUserRoles" cascade="all"> <key column="userId"/> <index column="lineItemIndex"/> <composite-element class="com.mislbd.iris.marketing.survey.UserRoles"> <property name="roleName"/> <property name="roleId"/> <property name="weight"/> <property name="description"/> </composite-element> </list> </class> </hibernate-mapping>
If want to execute the HQL
select a.name,b.roleName,b.description from UserDTO a inner join a.roles order by b.roleName
I got the follwing exception
Exception in thread "main" net.sf.hibernate.QueryException: collection of values in from clause: userdto0_.roles.elements [select a.name,b.roleName,b.description from com.mislbd.iris.marketing.survey.UserDTO a inner join a.roles order by b.roleName] at net.sf.hibernate.hql.PathExpressionParser.addFromCollection(PathExpressionParser.java:420) at net.sf.hibernate.hql.FromParser.token(FromParser.java:195) at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87) at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:120) at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:146) at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:133) at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:352) at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:330) at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1368) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1332) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1322) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1314) at com.mislbd.iris.marketing.survey.UserMain.main(UserMain.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at com.intellij.rt.execution.application.AppMain.main(Unknown Source) Process terminated with exit code 1
pls give me a solution
Regards
Banik
|