是一对一的关系吗,group by 不能根据对象吧,怎么的也有group by的字段吧
String queryString = " select o.xxx, sum(model.mouthNum) from BetInfo model left join fetch opeUser o "
+"where model.agentUser =? and model.opeTime >=? and opeTime <? and compleStore=?"
+" group by o.xxx";
这样试试
String queryString = " select o.xxx, sum(model.mouthNum) from BetInfo model left join fetch opeUser o "
+"where model.agentUser =? and model.opeTime >=? and opeTime <? and compleStore=?"
+" group by o.xxx";
这样试试
解决方案 »
- 菜鸟求教sockt编程
- 系统增加了hibernate就被卡死!?
- 在一个xnl配置文件中的代码sqlmap-config.xml.
- spring+hibernate的问题?
- 使用jBuilder2006开发EJB,在哪地方修改JNDI的名字
- 急求一段修改xml文件中节点的代码,谢谢!
- hibernate的MappingException
- 数据库采用连接池的WEB应用程序必须放在TOMCAT_HOME/webapps里面才能运行么?
- 请问各位谁手中有JSP页中数据分页显示的代码码
- SSH框架添加类别功能,Action报java.lang.NullPointerException错误
- clob初始化不能!请帮忙!
- 请教 acegi 权限设计 的问题
LZ把错误搞出来看看。直接查对象不知道成不成呀,有可能行。
但是group by 肯定有问题。String queryString = " select model.opeUser, sum(model.mouthNum) from BetInfo as model "
+"where model.agentUser =? and model.opeTime >=? and opeTime <? and compleStore=?"
+" group by model.opeUser.xxx";
这样似乎不行,查询项目中不是分组的字段,必须要在group by中
String queryString = " select model.opeUser.xxx, sum(model.mouthNum) from BetInfo as model "
+"where model.agentUser =? and model.opeTime >=? and opeTime <? and compleStore=?"
+" group by model.opeUser.xxx";
String queryString = " select model.opeUser.xxx, sum(model.mouthNum) from BetInfo as model "
+"where model.agentUser =? and model.opeTime >=? and opeTime <? and compleStore=?"
+" group by model.opeUser.xxx"; 这样执行肯定是可以的。关键的问题是我想返回opeUser实例是属于User ,我想返回User 对象
Iterator results = sess.createQuery(
"select model.opeUser, sum(model.mouthNum) from BetInfo as model "
+"where model.agentUser =? and model.opeTime >=? and opeTime <? and compleStore=? "
+"group by model.opeUser")
.list()
.iterator();
while ( results.hasNext() ) {
Object[] row = (Object[]) results.next();
OpeUser opeUser = (OpeUser) row[0];
Integer sum = (Integer) row[1];
.....
}