Hibernate 后台json封装

publicList<OrgVO>qryVO(){

Stringhql="selectnewcom.miniui.demo.vo.user.OrgVO(tbuo.TBasisOrg.orgId,tbuo.TBasisOrg.orgCode,tbuo.TBasisOrg.orgName,tbuo.TBasisOrg.orgDesc,tbuo.TBasisOrg.orgPid,tbuo.TBasisOrg.orgLevel,tbuo.TBasisOrg.isDisable,tbuo.TBasisOrg.orgAdd,tbuo.TBasisOrg.updateUser,tbuo.TBasisOrg.updateTime)fromTBasisUserOrgtbuo";

List<OrgVO>orgVOs=this.getCurrentSession().createQuery(hql).list();

returnorgVOs;

}

@SuppressWarnings({"deprecation","unchecked"})

@Override

publicList<OrgVO>qryVO2(){

Stringsql="SELECTORG_PIDASorgPid,ORG_IDASorgId,ORG_NAMEASorgNameFROMT_BASIS_ORG";

QuerysqlQuery=this.getCurrentSession().createSQLQuery(sql)

.addScalar("orgPid",Hibernate.STRING)

.addScalar("orgId",Hibernate.STRING)

.addScalar("orgName",Hibernate.STRING);

sqlQuery.setResultTransformer(Transformers.aliasToBean(OrgVO.class));

returnsqlQuery.list();

}

@Override

publicList<?>qryMap()

{

Stringhql="selectnewmap(e.busintypeidasid,e.busintypenameasname,e.busintypeidasnum,e.businremarkasdesc,e.updatetimeastime)fromTBasisTypeewhere1=1";

QueryhqlQuery=this.getCurrentSession().createQuery(hql);

List<?>list=hqlQuery.list();

returnlist;

}

@Override

publicList<?>qryMap2(){

Stringsql="SELECTBUSINTYPEID,BUSINTYPENAME,BUSINREMARK,STATUS,UPDATEUSERASusr,UPDATETIMEFROMT_BASIS_TYPE";

QuerysqlQuery=this.getCurrentSession().createSQLQuery(sql);

sqlQuery.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);

returnsqlQuery.list();

}

相关推荐