2.1.4:
I wrote a HQL to select an entity and its relations in HQL expecting to get a single object array with entity and collections of childs as its elements.
I know that its not necessary to select relations as Hibernate will fetch for me when required but in our case this fetch happens out of session scope(becuase we use session per operation, so no scope for lazy loading, no proxies, and lots of nos.. etc etc thats pathetic persistance architecture we had which is not in my control and no suggestions are acceptable here and there is no reason why session scope should not be at servlet filter or struts controller?!)
So please tell me whether its possible to get entity and one-many relationship data with a single HQL or I need to fire another HQL for getting relationship data.
Below is the exception I get when I execute above mentioned scenario.
net.sf.hibernate.QueryException: expecting 'elements' or 'indices' after: id [SELECT ro, ro.gvehma, cust, ro.saojobs FROM com.xxx.my.bms.valueobject.SaoRo ro, com.xxx.my.bms.valueobject.Gcust cust WHERE ro.custId = cust.c1cuid AND ro.status > '30' AND ro.roNo IS NOT NULL AND ro.roNo = ?]
at net.sf.hibernate.collection.CollectionPropertyMapping.toType(CollectionPropertyMapping.java:53)
at net.sf.hibernate.hql.PathExpressionParser.getPropertyType(PathExpressionParser.java:249)
at net.sf.hibernate.hql.PathExpressionParser.end(PathExpressionParser.java:288)
at net.sf.hibernate.hql.SelectPathExpressionParser.end(SelectPathExpressionParser.java:14)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:154)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114)
at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1554)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1525)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
Thank you very much..
Regards,
Surya.
|