sql语句 在数据库中可以执行 但在Hibernate的方法中查询不到结果 5
语句1:selectsum(orders.ticketPriceFull),sum(orders.cashMoney),sum(orders.ezpayMoney),su...
语句1:select sum(orders.ticketPriceFull),sum(orders.cashMoney),sum(orders.ezpayMoney),sum(orders.remitMoney),sum(orders.chequeMoney),sum(orders.ticketFacePriceFull),sum(orders.fuelPriceFull),sum(orders.quickCashMoney),sum(orders.electronicMoney),sum(orders.printInsuranceAmount),sum(orders.sellInsuranceAmount) from orders where 1=1 and orders.returnMoneyState='2016' and orders.firstLevelFlow in ('1018','1019') and 1=1 and orders.orderBelongToCompany='ZSHF' and orders.orderBelongCity='HRB'
语句2:select sum(orders.ticketPriceFull),sum(orders.cashMoney),sum(orders.ezpayMoney),sum(orders.remitMoney),sum(orders.chequeMoney),sum(orders.ticketFacePriceFull),sum(orders.fuelPriceFull),sum(orders.quickCashMoney),sum(orders.electronicMoney) from orders where 1=1 and orders.returnMoneyState='2016' and orders.firstLevelFlow in ('1018','1019') and 1=1 and orders.orderBelongToCompany='ZSHF' and orders.orderBelongCity='HRB'
Hibernate中的方法:
public List manyselect(String hql) {
Session session = this.getSession();
Transaction tx = null;
List results = null;
Query query;
try {
tx = session.beginTransaction();
query = session.createSQLQuery(hql);
results = query.list();//这u-28212 已u32463 把u25968 据u24211 中u30340 对u-29599 放u-28709 来u20102
tx.commit();
} catch (Exception e) {
} finally {
session.close();
}
return results;
}
语句1和语句2在数据库中都能执行 且能查询出结果 但通过上面的方法,语句2可以查询出结果 但语句1查询出结果为NULL
问题已解决 原因是 数据库新加的字段没有做Hibernate的重新映射 展开
语句2:select sum(orders.ticketPriceFull),sum(orders.cashMoney),sum(orders.ezpayMoney),sum(orders.remitMoney),sum(orders.chequeMoney),sum(orders.ticketFacePriceFull),sum(orders.fuelPriceFull),sum(orders.quickCashMoney),sum(orders.electronicMoney) from orders where 1=1 and orders.returnMoneyState='2016' and orders.firstLevelFlow in ('1018','1019') and 1=1 and orders.orderBelongToCompany='ZSHF' and orders.orderBelongCity='HRB'
Hibernate中的方法:
public List manyselect(String hql) {
Session session = this.getSession();
Transaction tx = null;
List results = null;
Query query;
try {
tx = session.beginTransaction();
query = session.createSQLQuery(hql);
results = query.list();//这u-28212 已u32463 把u25968 据u24211 中u30340 对u-29599 放u-28709 来u20102
tx.commit();
} catch (Exception e) {
} finally {
session.close();
}
return results;
}
语句1和语句2在数据库中都能执行 且能查询出结果 但通过上面的方法,语句2可以查询出结果 但语句1查询出结果为NULL
问题已解决 原因是 数据库新加的字段没有做Hibernate的重新映射 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询