Any one could help me in retrieving values from hibernate join queries!!!
The query in dao is
public List findSitebySystem(int sapSystemId)throws DataAccessException{
List sitebySystem=new ArrayList();
try{
sitebySystem=getHibernateTemplate().find("select s.siteName,s.siteId from TSite s,TSapsystem ss where ss.sapSystemId= s.sap_system_id and s.sap_system_id=1");
}catch(Exception e){
SecureSapLogger.error("Exception in findSitebySystem :: SiteDAO "+e,SiteDAO.class);
throw new DataAccessException("Exception in findSitebySystem :: SiteDAO");
}
return sitebySystem;
}
and the mapping hbm.xml is
<class name="com.securesap.hibernate.model.TSite" table="t_site" lazy="false">
<comment></comment>
<id name="siteId" type="int">
<column name="site_id" />
<generator class="identity" />
</id>
<property name="siteName" type="string">
<column name="site_name" length="30" not-null="true">
<comment></comment>
</column>
</property>
<property name="sap_system_id" column="sap_system_id" type="int" not-null="true"></property>
<property name="city" type="string">
<column name="city" length="30" not-null="true">
<comment></comment>
</column>
</property>
<property name="state" type="string">
<column name="state" length="30" not-null="true">
<comment></comment>
</column>
</property>
<property name="zip" type="string">
<column name="zip" length="30" not-null="true">
<comment></comment>
</column>
</property>
<property name="plantCode" type="string">
<column name="plant_code" length="30">
<comment></comment>
</column>
</property>
<property name="dateCreated" type="date">
<column name="date_created" length="19" not-null="true">
<comment></comment>
</column>
</property>
<property name="dateModified" type="date">
<column name="date_modified" length="19" not-null="true">
<comment></comment>
</column>
</property>
<set name="TSaproleBySapsystemAndSites" >
<key>
<column name="site_id" not-null="true">
<comment></comment>
</column>
</key>
<one-to-many class="com.securesap.hibernate.model.TSaproleBySap systemAndSite" />
</set>
<set name="TUsers" inverse="true">
<key>
<column name="site_id" not-null="true">
<comment></comment>
</column>
</key>
<one-to-many class="com.securesap.hibernate.model.TUser" />
</set>
I could get the result in eclipse hibernate console. I have retrieved a value in sitebySystem List .But i dont have a idea that how the values are stored in a list also how can i display the siteName and siteId from the List.
Help me regarding this.
I dont get any exception or error also no result.
Thanks in advance.


Reply With Quote