Select only the data you need into a simple VO using "select new", you can pick and choose which colums you want to go into the VO.
Here's an example:
Code:
@SuppressWarnings("unchecked")
public List<AdvancedSearchSitesResultsVO> findResultsVOListBySiteBucket(int siteBucketId){
String hql = "select new " + AdvancedSearchSitesResultsVO.class.getName() + "(\n"
+ " sbs.site.siteId,\n"
+ " sbs.site.siteRef,\n"
+ " sbs.site.siteName,\n"
+ " sbs.site.siteAdd1,\n"
+ " sbs.site.siteGroup.sgDesc,\n"
+ " sbs.site.tenancyType.tenancyType\n"
+ ")"
+ "from " + SiteBucketSite.class.getName() + " as sbs\n"
+ "where sbs.siteBucket.id = " + siteBucketId;
return (List<AdvancedSearchSitesResultsVO>)getHibernateTemplate().find(hql);
}
the VO:
Code:
public AdvancedSearchSitesResultsVO(
Integer siteId,
String siteRef,
String siteName,
String addr1,
String siteGroup,
String usageType
){
this.siteId = siteId;
this.siteRef = siteRef;
this.siteName = siteName;
this.addr1 = addr1;
this.siteGroup = siteGroup;
this.usageType = usageType;
}