Hibernate Dao查询出个问题
publicString[]getBillMess(longshopid,Stringstartdate,Stringenddate){String[]bill=null...
public String[] getBillMess(long shopid,String startdate,String enddate){
String[] bill = null;
try {
Session session = null;
session = this.getSession();
String hql = "select sum(c.consmoney),sum(c.reward) " +
"from Consume c " +
"where c.shopid in (select s.shopid " +
"from Shop s " +
"where s.parentshopid = ?) and " +
"c.paytype = '1' and c.consdate between ? and ? and returncode='0000'";
Query query = session.createQuery(hql);
query.setLong(0, shopid);
query.setString(1, startdate);
query.setString(2, enddate);
List<String[]> list = query.list();
System.out.println(list.size());
if(list.size()!=0){
bill = list.get(0);
}
} catch (Exception e) {
e.printStackTrace();
}
return bill;
}
bill = list.get(0);
这句居然会抛异常,后面跟前面都是String[]类型阿,郁闷阿。怎么解决? 展开
String[] bill = null;
try {
Session session = null;
session = this.getSession();
String hql = "select sum(c.consmoney),sum(c.reward) " +
"from Consume c " +
"where c.shopid in (select s.shopid " +
"from Shop s " +
"where s.parentshopid = ?) and " +
"c.paytype = '1' and c.consdate between ? and ? and returncode='0000'";
Query query = session.createQuery(hql);
query.setLong(0, shopid);
query.setString(1, startdate);
query.setString(2, enddate);
List<String[]> list = query.list();
System.out.println(list.size());
if(list.size()!=0){
bill = list.get(0);
}
} catch (Exception e) {
e.printStackTrace();
}
return bill;
}
bill = list.get(0);
这句居然会抛异常,后面跟前面都是String[]类型阿,郁闷阿。怎么解决? 展开
展开全部
Query query = session.createNativeQuery(hql);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
那句有异常?最可能是你的HQL有问题
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我支持一楼的看法 是应该把结果封装到POJO里面去 这样就不会出现类型转换问题
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询