hibernate 这个SQL 查询的返回值怎么封装成实体的
public BriefCarinfo findTopOne()
{
StringBuilder sql=new StringBuilder(); //"select base_2.id,base_2.carnu,base_2.oname,base_2.trademark,base_2.finalcareman from "
sql.append("select id, carnu, oname, trademark, finalcareman as finalcarename from");
sql.append(" ( ");
sql.append("select * from");
sql.append(" ( ");
sql.append("select * from ( select id, carnu, oname, trademark, finalcareman, yyyy, mm, dd from carinfo where id not in ( select id from sellgrouptmp ) ) sour where sour.mm=? and sour.dd>?");
sql.append(" union ");
sql.append("select * from ( select id, carnu, oname, trademark, finalcareman, yyyy, mm, dd from carinfo where id not in ( select id from sellgrouptmp ) ) sour where sour.mm=? and sour.dd<?");
sql.append(" union ");
sql.append("select * from ( select id, carnu, oname, trademark, finalcareman, yyyy, mm, dd from carinfo where id not in ( select id from sellgrouptmp ) ) sour where sour.mm=? and sour.dd>?");
sql.append(" union ");
sql.append("select * from ( select id, carnu, oname, trademark, finalcareman, yyyy, mm, dd from carinfo where id not in ( select id from sellgrouptmp ) ) sour where sour.mm=? and sour.dd<?");
sql.append(" ) ");
sql.append("where id not in (select DISTINCT carid from carelog where careresult='拒绝' and caredate BETWEEN (sysdate-30) and sysdate)");
sql.append(" ) where finalcareman is null and rownum=1 order by yyyy desc");
Date dateNow=new Date();
int mm=Integer.parseInt(new SimpleDateFormat("MM").format(dateNow));
int dd=Integer.parseInt(new SimpleDateFormat("dd").format(dateNow));
int nextFirstMm=MyCommonUtils.monthCircle(mm);
int halfFirstMm=MyCommonUtils.halfYearCircle(mm);
int halfNextMm=MyCommonUtils.monthCircle(halfFirstMm);
System.out.println(mm+" "+dd+" "+nextFirstMm+" "+dd+" "+halfFirstMm+" "+dd+" "+halfNextMm+" "+dd);
Object target=this.getHibernateTemplate().quertForObejctWithSQL(sql.toString(), new Object[]{mm,dd,nextFirstMm,dd,halfFirstMm,dd,halfNextMm,dd});
return (BriefCarinfo) target;
}