欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Hibernate 后台json封装 博客分类: Hibernate hibernate 

程序员文章站 2024-03-26 11:54:11
...
public List<OrgVO> qryVO() {
String hql = "select new com.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) from TBasisUserOrg tbuo";
List<OrgVO> orgVOs = this.getCurrentSession().createQuery(hql).list();
return orgVOs;
}

@SuppressWarnings({ "deprecation", "unchecked" })
@Override
public List<OrgVO> qryVO2() {
String sql = "SELECT ORG_PID AS orgPid,ORG_ID AS orgId, ORG_NAME AS orgName FROM T_BASIS_ORG";
Query sqlQuery = this.getCurrentSession().createSQLQuery(sql)
.addScalar("orgPid", Hibernate.STRING)
.addScalar("orgId", Hibernate.STRING)
.addScalar("orgName", Hibernate.STRING);
sqlQuery.setResultTransformer(Transformers.aliasToBean(OrgVO.class));
return sqlQuery.list();
}

@Override
public List<?> qryMap()
{
String hql = "select new map(e.busintypeid as id ,e.busintypename as name,e.busintypeid as num,e.businremark as desc,e.updatetime as time) from TBasisType e where 1=1";
Query hqlQuery = this.getCurrentSession().createQuery(hql);
List<?> list = hqlQuery.list();
return list;
}

@Override
public List<?> qryMap2() {
String sql = "SELECT BUSINTYPEID, BUSINTYPENAME, BUSINREMARK, STATUS, UPDATEUSER AS usr, UPDATETIME FROM T_BASIS_TYPE";
Query sqlQuery = this.getCurrentSession().createSQLQuery(sql);
sqlQuery.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP);
return sqlQuery.list();
}
相关标签: hibernate