String hql = "select a.measureID, a.Name, b.Name,c.Name from tblMeasure a, tblIndicator b, tblContentArea c, tblIndicatorMeasure d, tblContentAreaIndicator e where a.MeasureID = d.MeasureID and d.IndicatorID = b.IndicatorID and d.IndicatorID = e.IndicatorID and e.ContentAreaID = c.ContentAreaID";
org.hibernate.Query query = session.createQuery(hql);
SearchMeasureData searchData = new SearchMeasureData();
this is my HQL , if I run it on the sqlserver the above query is executing . But in program it's throwing an exception that TblMeasure is not mapped.
even though i have mapped TblMeasure.hbm.xml file in config file. Please give me suggessions.
Use class name instead of table name and use class property instead of column name in your HQL query.
Joined: Nov 03, 2008
Thanks for your reply,
I am able to run the query now with modification of a table name hbm.xml file.
After getting result set i am casting to a bean which has 4 attributes and getter and setter method. Please suggest me what to do.
String hql = "select a.measureId as measureNumber, a.name as measureName," +
" b.name as contentAreaName, c.name as indicatorName from" +
" TblMeasureBean a, " +
" TblIndicatorBean b, " +
" TblContentAreaBean c," +
" TblIndicatorMeasureBean d, " +
" TblContentAreaIndicatorBean e " +
" where a.measureId = d.measureId and " +
"d.indicatorId = b.indicatorId and" +
" d.indicatorId = e.indicatorId and" +
" e.contentAreaId = c.contentAreaId";
Hibernate: select tblmeasure0_.MeasureId as col_0_0_, tblmeasure0_.Name as col_1_0_, tblindicat1_.NAME as col_2_0_, tblcontent2_.NAME as col_3_0_ from EPHTN2.dbo.tblMeasure tblmeasure0_ cross join TBLINDICATOR tblindicat1_ cross join TBLCONTENTAREA tblcontent2_ cross join TBLINDICATORMEASURE tblindicat3_ cross join TBLCONTENTAREAINDICATOR tblcontent4_ where tblmeasure0_.MeasureId=tblindicat3_.MEASUREID and tblindicat3_.INDICATORID=tblindicat1_.INDICATORID and tblindicat3_.INDICATORID=tblcontent4_.INDICATORID and tblcontent4_.CONTENTAREAID=tblcontent2_.CONTENTAREAID
[Ljava.lang.Object; cannot be cast to com.scimetrika.actionhelpers.SearchMeasureBean
Joined: Dec 23, 2008
Please study the stack trace carefully and i am sure you will find the error.