hibernate 分页查询语句问题

我的一个语句在使用Oracle时正常运行,换成MySQL后不能正常使用了[code="java"]String hql = "from News n where n.entry.entryid in ("
+ "select e.entryid from Entry e where e.parentid=1 ) "
+ "or n.entry.entryid=1 order by n.lastmodifydate desc";
List tempList = basicMan.pagedQuery(hql, 1, 2);[/code][code="java"]public List pagedQuery(final String hql, int currentPage, final int pageSize) {

    if (currentPage == 0) {
        currentPage = 1;
    }
    final int curPage = currentPage;
    List list = getHibernateTemplate().executeFind(new HibernateCallback() {
        public Object doInHibernate(Session session)
                throws HibernateException, SQLException {

            Query query = session.createQuery(hql);
            List result = query.setFirstResult((curPage - 1) * pageSize)
                    .setMaxResults(pageSize).list();
            return result;
        }
    });
    return list;
}[/code]

错误代码如下[code="java"]Hibernate: select * from ( select news0_.NEWSID as NEWSID2_, news0_.ENTRYID as ENTRYID2_, news0_.NEWSTITLE as NEWSTITLE2_, news0_.CONTENT as CONTENT2_, news0_.KEYWORDS as KEYWORDS2_, news0_.LASTMODIFYDATE as LASTMODI6_2_, news0_.ORDERINDEX as ORDERINDEX2_, news0_.PICPATH as PICPATH2_ from zkq1f1_db.news news0_ where news0_.ENTRYID in (select entry1_.ENTRYID from zkq1f1_db.entry entry1_ where entry1_.PARENTID=1) or news0_.ENTRYID=1 order by news0_.LASTMODIFYDATE ) where rownum <= ?
Exception in thread "main" org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:615)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)
at com.kcheng.dao.BasicDImp.pagedQuery(BasicDImp.java:169)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy5.pagedQuery(Unknown Source)
at test.my.dao.TestDao.main(TestDao.java:38)
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query[/code][code="java"]Caused by: java.sql.SQLException: Every derived table must have its own alias[/code]

在不使用分页的情况下页正常运行

怎么没有人来帮助呢,提示一下也好啊
[b]问题补充:[/b]
query.setFirstResult((curPage - 1) * pageSize)

.setMaxResults(pageSize).list();
hibernate这种方式也一样啊
[b]问题补充:[/b]
确实问题出在[code="java"]query.setFirstResult((curPage - 1) * pageSize)

.setMaxResults(pageSize)[/code]
但是这是为什么呢?应该怎么改呢
[b]问题补充:[/b]
产生的sql语句是rownum <= ? 需要改成limit 但是hql该怎么改呢
[b]问题补充:[/b]
照你那样改的话代码改动蛮大,现在是因为转移数据库的时候出了问题,就是说代码不想去做大的改动了

5个回答

楼主oracle改成mysql数据库,hibernate.dialect,class映射generator类型改过了没有?
mysql :
hibernate.dialect:org.hibernate.dialect.MySQLInnoDBDialect
generator:native

mysql 分页是用limit

那你把sql语句在mysql中执行一遍看行不.
Every derived table must have its own alias

每一个表都必须有自己的别名

楼主你返回的是List那就查出所有记录在人为处理分页(不推荐,记录不多的情况下可用).下面是我的处理方式.
[code="java"]public Page getPage(int pageNo, int pageSize) {
Page page = null;
int startIndex = Page.getStartOfPage(pageNo, pageSize);
SQLQuery sqlQuery = getSession().createSQLQuery("SELECT COUNT(id) FROM order");
int totalCount=((BigInteger) sqlQuery.list().get(0)).intValue();
if(totalCount<1){
page = new Page();
}else{
Query query = getSession().createQuery("from Order o left join fetch o.Customer");
query.setFirstResult(startIndex).setMaxResults(pageSize);
page = new Page(startIndex, totalCount, pageSize, query.list());
}
return page;
}[/code]

[color=red]照你那样改的话代码改动蛮大,现在是因为转移数据库的时候出了问题,就是说代码不想去做大的改动了 [/color] 那你去手写sql查询吧!

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
关于分页查询语句的问题......
我是刚学Access,不足之处,请各位大虾指教!!!rnpublic DataSet getPagedInfo(string tbName, int index, int count, out int rowCount)rnrn string sql = "select top " + count + " * from " + tbName + " where [ID] not in (select top " + index * count + " [ID] from " + tbName + ")";rnrn OleDbConnection mconCurrent = GetConn();rn DataSet ds = new DataSet();rn mconCurrent.Open();rn int res = 0;rn rowCount = getInfoCount(tbName);//这里可以拿到查询表的总记录数rn tryrn rn OleDbDataAdapter oleDt = new OleDbDataAdapter(sql, mconCurrent);rn oleDt.Fill(ds);rn return ds;rn rn finally closeConn(mconCurrent); rnrnrn程序运行传入的参数 (JobInfo,0,4,out rCount) 生成语句select top 4 * from JobInfo where [ID] not in (select top 0 [ID] from JobInfo);在运行到oleDt.Fill(ds);这句时程序报错:【System.Data.OleDb.OleDbException: 语法错误。 在查询表达式 '[ID] not in (select top 0 [ID] from JobInfo)' 中】,但是我在sql server里面可以运行这个语句,这到底是什么原因???
分页查询语句 问题
select * from 表名 where rowid in (select ID from (select rownum rn,ID from (select rownum ID from 表名)where rownum<4)where rn>1)rnrn 只显示2条数据? 数据库有15条数据 显示第二行和第十一行这两天数据啊?哪里错了啊?
分页查询语句的效率问题
[size=large][b]一般的分页sql如下所示:[/b] [/size] [code=&quot;java&quot;]sql1:select * from (select t.*,rownum rn from XXX t)where rn&gt;0 and rn
hibernate查询语句问题!
hibernate查询语句如下:rnrnQuery q = sess.createQuery("from TUserBean user,TOrgBean org "rn+ "where user.userOrgId=org.orgId and org.state='A' "rn+ "and user.state = 'A' start with org.orgId='"+orgId+"' rnconnect by prior org.orgId = org.parentOrgId order by user.createDate desc");rnrn报错信息:rnorg.hibernate.hql.ast.QuerySyntaxException: unexpected token: start near line 1, column 161 [from cn.com.bean.TUserBean user,cn.com.bean.TOrgBean org where user.userOrgId=org.orgId and org.state='A' and user.state = 'A' start with org.orgId='876' connect by prior org.orgId = org.parentOrgId order by user.createDate desc]rnrn是hibernate不支持start with?还是写错了?删掉start with org.orgId='"+orgId+"' connect by prior org.orgId = org.parentOrgId就不会报错。
hibernate的hql查询语句问题
两个对象rnpublic class Manager rn private Integer id; //管理员ID号rn private String name; //管理员名称rn private String pwd; //管理员密码rn private Purview purview;rn 省略set和get方法rnrnrnpublic class Purview rn private Integer id;rn private int sysset=0; //系统设置权限rn private int readerset=0; //读者管理权限rn private int bookset=0; //图书管理权限rn private int borrowback=0; //图书借还权限rn private int sysquery=0; //系统查询权限rn private Manager manager;rn 省略set和get方法rnrnrnrn方法query_prnpublic Manager query_p(String str) rn String hql = "select m.*,p.sysset,p.readerset,p.bookset,p.borrowback,p.sysquery from Manager m rn left join Purview p on m.id=p.id where m.name='"+str+"'";rn Manager manager1 = (Manager)this.getHibernateTemplate().find(hql).get(0);rn return manager1;rn rnrnrn我写这个方法返回Manager类型,但是不对rn问:应该怎么写,才能实现联合查询返回Manager,Manager类里的purview也要有值。rnrn
hibernate hql查询语句问题;
我想检查用户是否存在:rnhql语句让如下:rn[code=Java]rnrnString hql="from UserBean where name=? and password=?";rnint b=session.createQuery(hql).setParameter(0,user.getName())rn .setParameter(1,user.getPassword())rn .executeUpdate();rn[/code]rnrnrn[code=Java]rnorg.hibernate.hql.ast.QueryTranslatorImpl.errorIfSelect(QueryTranslatorImpl.java:301)rn org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:418)rn org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:283)rn org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1168)rn org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:117)rn com.chengge.dao.impl.UserDaoImpl.checkUser(UserDaoImpl.java:36)rn com.chengge.service.impl.UserServiceImpl.checkUser(UserServiceImpl.java:24)rn com.chengge.action.UserAction.login(UserAction.java:25)rn sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rnrn[/code]rnrnrn不过报错了。还有我想知道如果用户存在,b的值会是多少?是1吗?rnhql语句中有没只返回一行数据的语句的(list()方法和iterator()方法是返回集合的)?
Hibernate 查询语句的问题
Integer total = Integer.parseInt(hibernateTemplate.find("[color=#FF0000]select count(*) from Material m inner join fetch m.material_supplier s where 1=1[/color]").listIterator().next().toString());rn报hibernate语句错误,这个语句该怎么写呢?rnwhere后面是要加 m表和s表的筛选条件的。
hibernate 查询语句问题
我今天修改别人代码时发现这样的查询语句(Hibernate)rnrnrnStringBuffer sql = new StringBuffer("select * from T_Xtzd_zhbz xt where xt.deletedFlag = " + CssConst.NOTDELETED);rn sql.append(" START WITH xt.sjzd is null and xt.xtzdk = '"+CssConst.XTZDK_WZFL+"' CONNECT BY Prior xt.xtzdid = xt.sjzd order by xt.zdpx ");rn ResultSet rs = executeJdbcQuery(sql.toString());rn没看懂,有知道的大神给小弟解释下这个查询语句的意思,(START WITH,CONNECT BY Prior都没见过,啥意思啊)叩谢!叩谢!叩谢!rn希望能给小弟讲解详细一点哦~多谢各位了
MySql Hibernate 查询语句问题
[code=Java]rnselect rn mem.routId, rn mem.memCode, rn r.routName, rn r.ipaddress, rn min(mem.usedValue) as minUsedValue, rn max(mem.usedValue) as maxUsedValue, rn avg(mem.usedValue) as avgUsedValue rn from Net_Cap_Mem mem, Net_Routinfo r rn where mem.routId=r.routId and recordTime>='2010-03-04 16:56:56' and recordTime<='2010-03-08 15:29:26' rn and mem.routId in (select plan.goId from Net_Gatherpublicobject plan where plan.gmId=2) group by mem.routId order by avgUsedValue descrnrnrn[/code]rnrn上面是一个Mysql+Hibernate查询语句rn 最后我想用 字段 avg(mem.usedValue) as avgUsedValue 排序 rn 问题:rn 我把这语句放入代码中执行就报错!说是找不到 avgUsedValue 这个字段rn 直接放入 数据库中可以正常查询到数据!rnrnrn 这是上面问题,应该怎么解决????
hibernate查询语句问题
String hql = "from ybdeviceapplyform where strapplyername = '"+ strapplyername +"' and strtitle = '"rn + strtitle +"' and odtapplytime >= '"+ startdt +"' and odtapplytime <= '"+ enddt +"'";rnrn这是我的hibernate查询hql。。。为什么报org.springframework.orm.hibernate3.HibernateQueryException: ybdeviceapplyform is not mapped啊。。。
hibernate关于查询语句问题
我现在有一个number表,知道name这个参数,如何使用getHibernateTemplate()方法来取出这条数据?
Oracle分页查询语句
 Oracle的分页查询语句基本上可以按照本文给出的格式来进行套用。分页查询格式:SELECT * FROM (SELECT A.*, ROWNUM RN FROM (SELECT * FROM TABLE_NAME) A WHERE ROWNUM )WHERE RN >= 21其中最内层的查询SELECT * FROM TABLE_NAME表示不进行翻页的原始查询语句。ROWNUM
分页查询语句
本人是个初学者,想问一下在分页时用什么样的方法最好?还要句括条件查询后的分页.数据库用的是Oracle
Hibernate查询语句
1 HQL的基本语法     select "属性名" from "对象"      where "条件"     group by "属性名" having "分组条件"     order by "属性名" desc / asc 2 实体对象查询    from User 3 动态实例化对象查询    select new User(id, name) from User 4
hibernate的查询语句
hibernate都多少种查询语句,我只知道hql和Criteria,[color=#FF0000]大家喜欢用哪种[/color]?rn听说hql还是要防[color=#FF0000]注入式攻击[/color]的,不知道Criteria有没有这个问题?
Hibernate的查询语句
查询对象1中的用户名 ,查询属性 @Test public void testQueryUser1(){ // TODO Auto-generated method stub SessionFactory sf = null; Session session = null; Transaction ts = null; try {  sf = HibernateUtil.g...
Hibernate 查询语句
select top(3) * from Song order by hits desc rn像这样的查询语句在hibernate里要怎么写成HQL语句啊 我就是想查询下hits最大的那几列
hibernate 查询语句
今天看到 hibernate 的find方法打印的sql语句,很奇怪,为什么一个select语句可以嵌入另一select语句 rnrnfrom里面呢,我知道的这种情况应该是子查询,不都应该嵌入到where查询条件中的吗?有懂的大牛帮我解析一下啊,感激不尽!rn控制台答应的语句如下:rnrnHibernate:rnrn selectrn * rn fromrn ( selectrn distinct tkcbh0_.KCBHID as KCBHID36_,rn tkcbh0_.CKDID as CKDID36_,rn tkcbh0_.CKRK as CKRK36_,rn tkcbh0_.CREATEDBY as CREATEDBY36_,rn tkcbh0_.CREATEDTIME as CREATEDT3_36_,rn tkcbh0_.CRKSJ as CRKSJ36_,rn tkcbh0_.CRKSL as CRKSL36_,rn tkcbh0_.CZR as CZR36_,rn tkcbh0_.DElETEDBY as DElETEDBY36_,rn tkcbh0_.DELETEDFLAG as DELETEDF6_36_,rn tkcbh0_.DELETEDTIME as DELETEDT7_36_,rn tkcbh0_.MODIFIEDBY as MODIFIEDBY36_,rn tkcbh0_.MODIFIEDTIME as MODIFIED8_36_,rn tkcbh0_.RKDID as RKDID36_,rn tkcbh0_.WZID as WZID36_ rn fromrn t_kcbh tkcbh0_ rn wherern (rn tkcbh0_.DELETEDFLAG=0 rn )rn and(rn tkcbh0_.WZID=? rn ) rn order byrn tkcbh0_.CRKSJ desc ) rn wherern rownum <= ?
hibernate分页问题
望高手相救rnrn小弟用hibernate提供的分页手段却总是报错,我用的oracle版本是9irnCriteria criteria=session.createCriteria(AgentA.class);rncriteria.setFirstResult((pageNum-1)*10);rncriteria.setMaxResults(perPageNum);rnList list=criteria.list();rn我把中间的动态加条件的代码也全去掉了,最后发现问题在于初始页和记录数上rn报错如下rnrn2007-5-14 18:08:55 org.hibernate.util.JDBCExceptionReporter logExceptionsrn警告: SQL Error: 17041, SQLState: nullrn2007-5-14 18:08:55 org.hibernate.util.JDBCExceptionReporter logExceptionsrn严重: 索引中丢失 IN 或 OUT 参数:: 1rn一直知道oracle的分页和sqlserver有很大区别,但在网上查文章看到有很多朋友rn就是用hibernate提代的分页来做的,这令我非常的费解.(用query来做也是报这个错)rn控制台生成的SQL语句为rnselect * from ( select agenta0_ agenta0_.ISNEW as ISNEW18_ from ESCA.AGENT_A agenta0_ ) where rownum <= ?rnrn问题目肯定出自rownum这一块...rn希望高手能出手拉小弟一把rnrn
hibernate 分页问题
rnrnrnrn<%rn String hql="from Addnew a where a.lb1='企业新闻' ";rn int totalRows=hn.query(hql).size();rn int index=0;rn int amount=5;rn String firstID=request.getParameter("firstID");rn String lastID=request.getParameter("lastID");rn if(firstID!=null)rn int id=Integer.parseInt(firstID);rn index=id-amount-1;rn if(index<0)rn index=0;rn rn rn if(lastID!=null)rn int id=Integer.parseInt(lastID);rn index=id;rn if(index>totalRows)rn index=totalRows;rn rn rn List pageNew=hn.query(hql,index,amount);rn Addnew firstNew=(Addnew)pageNew.get(0);rn int last=amount-1;rn if(last>pageNew.size())rn last=pageNew.size()-1;rn rn Addnew lastNew=(Addnew)pageNew.get(last);rn %>rn rn 共有 <%out.print(totalRows); %> 条商品信息 rn <%if(index>0) %> 上一页<% %>rn <%if(index+amount 下一页<% %> rnrnrnrn可以显示本页的数据 当点击下一页时出现数组下标越界 问题是没有从数据库中获得数据给list所致,但是我不知道具体是哪的问题导致。rnrnjava.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.get(ArrayList.java:322) at org.apache.jsp.basic.new_jsp._jspService(new_jsp.java:171) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:384) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:216) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:634) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445) at java.lang.Thread.run(Thread.java:619) rnrnrnrnrnrn
关于Hibernate分页问题
我在网上找到了一个分页类她的构造函数如下:用户每点一页都要构造一个HibernatePage类,请问我是否要把入参Query放入该用户的Session中?rnrn public HibernatePage(Query query, int pageNumber, int pageSize)rn rn this.pageNumber = pageNumber;rn this.pageSize = pageSize;rn tryrn rn ScrollableResults scrollableResults = query.scroll();rn //get the total elements numberrn scrollableResults.last();rn this.totalElements = scrollableResults.getRowNumber();rn if (Integer.MAX_VALUE == this.pageNumber || this.pageNumber > getLastPageNumber()) //last pagern rn this.pageNumber = getLastPageNumber();rn rn elements = query.setFirstResult((this.pageNumber - 1) * this.pageSize).setMaxResults(this.pageSize + 1).list();rn catch (HibernateException e)rn rn throw new RuntimeException(e);rn rn
Hibernate分页问题
使用hibernate调用自己的分页类 第一页数据出来了 但是没有下一页的数据 页码也没有 走断点总记录数和页码的分组数都计算出来了rn这是分页类rnpackage cn.jbit.renting.bean;rnrnrnrnimport java.io.Serializable;rnimport java.util.ArrayList;rnimport java.util.List;rnrn/**rn * Java Beanrn * @author Administratorrn *rn */rnpublic class Pager implements Serializablernrn//public static final int PAGE_RECORD = 6;rnpublic static final int GROUP_RECORD = 5;//显示几组rnpublic static int page_record;//每页显示几条数据rnprivate int currentPage; // 当前页码rnprivate int pageCount; // 总页数rnprivate int recordCount; // 总记录数rnrnprivate int currentGroup; // 当前组数rnprivate int groupCount; // 总组数rnprivate List groupList; // 页面中需要的分组页索引rnpublic int prevPage;rnpublic int nextPage;rnrnpublic int getPage_record() rnreturn page_record;rnrnrnpublic void setPage_record(int page_record) rnthis.page_record = page_record;rnrnrn// 构造函数rnpublic Pager(int page)rncurrentPage = page;rnrnrn// 获取当前页页码rnpublic int getCurrentPage()rnreturn currentPage;rnrnrn// 获取下一页页码rnpublic int getNextPage()rnif(currentPage < pageCount)rnreturn currentPage+1;rnelsernreturn pageCount;rnrn// 获取上一页页码rnpublic int getPrevPage()rnif(currentPage <= 1)rnreturn 1;rnelsernreturn currentPage - 1;rnrnrn// 获取当前组数rnpublic int getCurrentGroup()rnreturn currentGroup;rnrnrnpublic List getGroupList()rn// 计算当前组数rncurrentGroup = (int)Math.ceil((float)currentPage / GROUP_RECORD);rnrngroupList = new ArrayList();rnint start = (currentGroup-1) * GROUP_RECORD;rnint end = (start + GROUP_RECORD) < pageCount ? start + GROUP_RECORD : pageCount;rnfor (int i = start + 1; i <= end; i++) rngroupList.add(i);rnrnreturn groupList;rnrnrnrn// 获取总页数rnpublic int getPageCount()rnreturn pageCount;rnrnrn// 设置总记录数rnpublic void setRecordCount(int recordCount) rnthis.recordCount = recordCount;rnpageCount = (int)Math.ceil(((float)recordCount / page_record));rnrnrn// 获取总记录数rnpublic int getRecordCount() rnreturn recordCount;rnrnrnrnrnrnrn方法调用rn/***rn* 分页rn*/rnpublic List SearchpageHouse(Pager pager) rnif(pager.getRecordCount() == 0)rnpager.setRecordCount(getHouse().size());//总共多少条记录rnrnString hql="from House";rnrnQuery query=session.createQuery(hql);rnint start=(pager.getCurrentPage() - 1) * Pager.page_record;//起始位置rnquery.setFirstResult(start);rnquery.setMaxResults(start + Pager.page_record);//结束为止rnrnList list=query.list();rnreturn list;rnrnrnrnrnrnrnservlet里的调用rnpublic void doPost(HttpServletRequest request, HttpServletResponse response)rnthrows ServletException, IOException rnrnresponse.setContentType("text/html;UTF-8");rnresponse.setCharacterEncoding("UTF-8");rnrequest.setCharacterEncoding("UTF-8");rnPrintWriter out = response.getWriter();rn// HouseBiz house=new HouseBizImpl();rn// List houses=house.getHouse();rn// request.setAttribute("houses", houses);rn// request.getRequestDispatcher("MyJsp.jsp").forward(request, response);rnHouseBiz hb=new HouseBizImpl();rnString page=request.getParameter("page");rnint p=1;rnif(page!=null&&!(page.equals("")))rnrnp=Integer.parseInt(page);rnrnPager pager=new Pager(p);rnpager.setPage_record(3);//每页显示三条记录rnrn//int size=2;rn//List list=hb.getpageHouse(index, size);rnList list=hb.SearchpageHouse(pager);rn// int count=hb.getHouse().size();rn// int topage=(count%size==0)?(count/size):(count/size+1);rn//request.setAttribute("topage", topage);//最大页码rnrequest.setAttribute("houses", list);rn//request.setAttribute("index", index);//当前页码rnrequest.setAttribute("paper", pager);rnrequest.getRequestDispatcher("MyJsp.jsp").forward(request, response);rnrnjsp页面rnrnrnrnrnrnrn rn rn rn $houses.titlern 修改rn 删除rnrnrnrn rn $houses.street_id.name--$houses.street_id.distrct_ID.namernrn rn 联系电话:$houses.contactrnrnrn rnrnrn上一页rnrnrn$irnrnrn$i rnrnrn下一页rn
struts2 hibernate 分页问题
先吐槽一下 刚刚复制了一段代码网页直接崩溃,楼主辛苦的描述得重写[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/8.gif][/img]rnrn最近按照视频教学做了一个简单的struts2 hibernate小练习rn用户注册 查看所有用户 删、改单个用户 也就是增删改查了rnrn我想在查询出来的结果上加个分页功能,试了几个小时,一直失败,求大神指点[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/17.gif][/img]rnrn原来的com.xxx.model只有一个Person 几个属性rn我按照书上jsp+hibernate分页的例子 加了个PageModel rnprivate int currPage;rnprivate int totalRecords;rnprivate List list;rnprivate int pageSize;rn把以前返回的list放在这个里面 想返回pageModel对象 然后再获得里面的list 从而达到和以前一样的jsp页面效果,但中间代码写的应该问题很大,新手求大神帮帮忙-----rnrn[color=#000000]之前的PersonAction[/color][color=#FF0000][/color] (自认为不重要的部分省略,这里我只列出了一个方法(增,)里面包含了查,)rnprivate int id;rnprivate String username;rnprivate String password;rnprivate int age;rnpublic String savePerson()throws Exceptionrn Person person =new Person();rn person.setUsername(username);rn person.setPassword(password);rn person.setAge(age);rn java.sql.Date registerDate=new java.sql.Date(new java.util.Date().getTime());rn person.setRegisterDate(registerDate);rn //把页面的值放到person里面rn rn PersonService personService=new PersonServiceImpl();rn personService.savePerson(person);rn //通过PersonService借口实例化一个对象把person对象的值存入数据库rn List list=personService.listAllPersons();//把值放入list中rn HttpServletRequest request=ServletActionContext.getRequest();rn request.setAttribute("list", list);//把list的值传到request中rn return SUCCESS;rn rnrn[color=#000000]我自己乱改后的代码[/color]rnPerson person = new Person();rn person.setUsername(username);rn person.setPassword(password);rn person.setAge(age);rn java.sql.Date registerDate = new java.sql.Date(rn new java.util.Date().getTime());rn person.setRegisterDate(registerDate);rn // 把页面的值放到person里面rnrn PersonService personService = new PersonServiceImpl();rn personService.savePerson(person);rn // 通过PersonService借口实例化一个对象把person对象的值存入数据库rn HttpServletRequest request = ServletActionContext.getRequest();rnrn String page = request.getParameter("currPage");rn int currPage = 1;rn int pageSize = 5;rn if (page != null) rn currPage = Integer.parseInt(page);rn rn PageModel pageModel = personService.findPaging(currPage, pageSize);rn request.setAttribute("pageModel", pageModel);// 把list的值传到request中rnrn return SUCCESS;rnrnrn[color=#FF00FF]jsp页面原来的代码[/color]rn rn rn rn usernamern passwordrn agern registerDatern updatern deletern rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn updatern rn rn deletern rn rn rn rn rnrnrn[color=#FF0000]更改之后的jsp代码[/color] rnrnPersonAction代码被我改乱了 之前进入index.jsp后数据库时能插入 注册信息的,但是跳转不到listAll.jsp 显示所有注册信息的页面 。。rnrn求大神 分析下 action 还有 jsp ognl表达式那里应该怎么写,以及其他错误rn跪谢[img=https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/onion/18.gif][/img]rnrnrn如果谁有struts2 hibernate分页的例子 能发个给我看看 也OK啦 rn179165117@qq.com 收到后 测试完立刻结贴
关于hibernate 分页问题
师兄们 情况是这样的:rn 表里一共有11条数据。但是每次读取全是前十条,我不知道剩下的一条在哪里,JSP页面上也是现实就一页rn rn
请教 Hibernate分页问题
q.setFirstResult(10000); rnq.setMaxResults(10);rnrn这样是没什么问题,但生成的sql语句是 select top 10010 .......rn如果更大的数据分页比如10W或更多,在后面几页里翻页时,速度会明显变慢。rnrn我通过什么方式可以让Hibernate只从10000条数据开始取,取10条?rnrn请求各位帮助
hibernate分页问题sqlsever的
String hql="from ResContent r where r.catalogid='"+cid+"' order by r.id desc";rnQuery queryObject=resContentDAO.getSession38().createQuery(hql);rnqueryObject.setFirstResult(0);rnqueryObject.setMaxResults(15);rnnewslist=queryObject.list();rn分页的时候取第一页特快,rnqueryObject.setFirstResult(15);rnqueryObject.setMaxResults(15);rnnewslist=queryObject.list();就这一步太慢了rn可是取第2页慢的一动不动,我知道这样分如果是 sqlsever的话特没效率,但也不至于不动吧,是不是我还有些地方没注意啊有谁知道解决方法吗
解决HIbernate分页问题
Hibernate Criteria分页产生的问题大家都知道做分页必须要知道总记录数,这就为我们出了一到小题儿,往往我们直接用Criteria调用list方法就返回全部查询结果了,但是分页必须在返回列表之前得到总行数。我之前的做法是写两个方法,参数完全一样,一个返回Integer,也就是记录数,一个返回List,结果集。这样写感觉挺麻烦的,还有人直接用criteria.list()返回记录数,再设...
hibernate 分页限制问题?
我在hibernate中用setFirstResult setMaxResult rnList items = criteria.setFirstResult((pageno - 1) * pageSize).setMaxResults(pageSize).list();rn这样我只能实现翻页,但数据太多有7W条且关联表多,翻到最后一页时非常慢。rn我现在想只查询出前500条数据来分页,有什么好办法。rn谢谢各位!
有关Hibernate分页的问题
以下代码是Spring封装Hibernate分页的实现,哪位大侠能帮我注释一下,最好详细点,谢谢了rnrnrnrnrnrnpublic class PageHibernateDaoSupport extends HibernateDaoSupport rn rn public List findByPage(final String hql, final int offset, final int pageSize) rn List list = getHibernateTemplate().executeFind(new HibernateCallback() rn public Object doInHibernate(Session session)rn throws HibernateException, SQLException rn List result = session.createQuery(hql)rn .setFirstResult(offset)rn .setMaxResults(pageSize).list();rn return result;rn rn );rn return list;rn rn rn
Hibernate的分页问题
用Hibernate可以出到从某行到某行就容易实现了,用rnc.SetFirstResult(pi.FirstResult);rnc.SetMaxResults(pi.MaxResults);rnc.List();但是rn怎样算出一共有多少个记录,我却搞了几天都搞不出来。rn如果用select count(*) from table就容易,但是,我偏偏用了ICriterion这种查询方式,rn有什么办法得到ICriterion这个条件的最大行呢?rn请各位高手帮忙。谢谢
Hibernate 分页的问题?
在Hibernate中分页。rn对于Query我可以通过setFirstResult来设置第一条的位置rn通过setMaxResults来设置条数rnrn问题是。。。。我该怎么来得到所有的条数啊。。。。就是如果我不设置上面两个参数。。。query会返回多少行。。。。。。。。。。。rnrn只有上面三个参数都有才能在HTML上形成。。。如下的样子:rn 第一页 上一页 1 2 3 4 5 6 7 下一页 最后页rnrn我实在不知道要怎么样获得总条数。。rnrn请指教。。。???rn不知我有没有描述清楚我的问题◎#%◎……#¥rnrn
Hibernate 分页的问题
请问用Hibernate的话,如和处理分页的问题rnrn有没有经典的方法,我知道可以 第一次 select count(*) 得出行数,然后 用mysql的limit,得到每一页rnrnrn我想知道是否有比较好的方法,能简化分页
Hibernate分页问题!!
在dao包的Hibernate类中rn public List findAllSearch(int pageNo , int pageSize)rn Session session = this.getSession() ;rn Query query = session.createQuery("from test") ;rn int firstResultIndex = pageSize*(pageNo-1) ;rn query.setFirstResult(firstResultIndex) ;rn query.setMaxResults(pageSize) ;rn return query.list() ;rn rnrn在servlet中调用rn try rn request.setAttribute("all", new Hibernate().findAllSearch(1, 5));rn catch (Exception e) rn e.printStackTrace() ;rn finallyrn HibernateSessionFactory.closeSession() ;rn rnrn在jsp中rn rn This is my JSP page. rn rn rn rn rn $o.name rn rn rn rn rnrn怎么控制上一页和下一页??
hibernate 一对多分页问题
已配置好struts + spring + hibernate,并配置好一对多,查询、插入、删除均一切正常,可是在实现分页功能,遇到点问题。rnrn[code=Java]rnpublic List Ct2ById(final int first, final int length)rn final String hql = "from Category where id = 3";rn List list = getHibernateTemplate().executeFind(new HibernateCallback() rn public Object doInHibernate(Session session) throws HibernateException, SQLException rn Query query = session.createQuery(hql);rn query.setFirstResult(first);rn query.setMaxResults(length);rn List list = query.list();rn return list;rn rn );rn return list;rn [/code]rnrn[code=XML]rnrn rn rn rn rn rn rn rn rn rn rn rn rnrn[/code]rnrn之前使用 getHibernateTemplate().find(hql)的时候——查询、插入、删除均一切正常,可是现在换成这分页代码就出现点问题了rn如果int first=0,不过length为多少,均会把所有记录都查询出来,没有实现分页。rn如果int first=1或者大于0,就查询不出记录了。rn静待各位兄弟姐妹们赐招。
hibernate + extJs3.1分页问题
我用的hibernate 的查询语句rnrn Query query=session.createQuery("form xxx");rn query.setFirstResult(page.start); stat=当前页-1*30rn query.setMaxResults(30);rn rnextjs是gridpanel中的分页是rnrnrnbbar: new Ext.PagingToolbar(rn store: store,rn displayInfo: true,rn pageSize: 30,rn prependButtons: true,rn displayMsg : "显示第 0条到 1条记录,总共 2条", rn emptyMsg : "没有记录",rnrnrn为什么分页不能正常出来呢,query.setMaxResults(30)设置的结果是多少 就只有多少条记录数,所以只有一页,请教hibernate+extJS gridpanel的分页rn rn
hibernate自带的分页问题
public PageViewObject getOnePageMultiResult(Session session,rn Query queryObj,Query otherQuery, Integer pageCount,rn Integer currPage) throwsrn HibernateException rn PageViewObject pageViewObject = new PageViewObject();rn String sqlCount = null;rn List ls = queryObj.list();rn List ls1 = otherQuery.list();rn int totalSize = 0;rn if (ls != null && ls.size() > 0)rn totalSize = ls.size();rn if (ls1 != null && ls1.size() > 0)rn totalSize = totalSize + ls1.size();rn rn int perPageCount = pageCount.intValue();rn int currentPage = currPage.intValue();rn if (perPageCount == 0)rn perPageCount = totalSize;rn queryObj.setFirstResult(perPageCount *rn ( (currentPage == 0) ? 0 :rn currentPage - 1));rn queryObj.setMaxResults(perPageCount);rn List results = queryObj.list();rn List results_1 = otherQuery.list();rn results.addAll(results_1);rn pageViewObject.setRowList(results);rn pageViewObject.setTotalCount(totalSize);rn pageViewObject.setPerPageCount(perPageCount);rn return pageViewObject;rn rnrnrn这是hibernate的自带分页吧?我在查询的时候用这个分页,数据量小(300条内)的时候就能显示在页面,当数据量大(上千条)的时候事物就自动回滚了(我打印了下时间执行分页前后数据量多的时候用了90多秒),后台显示这个:rn2011-11-15 12:21:52 org.objectweb.jotm.TransactionImpl timeoutExpiredrn信息: set rollback only (tx=bb14:38:0:0100b496591fb984b3...0f7005:)rnorg.springframework.transaction.TransactionSystemException: Could not commit Hibernate transaction; nested exception is net.sf.hibernate.TransactionException: Commit failed with exception: rnnet.sf.hibernate.TransactionException: Commit failed with exception: rnat net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.java:61)rnat org.springframework.orm.hibernate.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:472)rnat org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:397)rnat org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:243)rnat org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:66)rnat org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)rnat org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)rnat $Proxy20.getWholeSheetAlerts(Unknown Source)rnat com.hollycrm.unicom.sheet.monitor.web.SheetMonitorAction.execTotalSheetMonitor(SheetMonitorAction.java:312)rnat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rnat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rnat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rnat java.lang.reflect.Method.invoke(Method.java:324)rnat com.hollycrm.springframework.web.struts.DispatchActionSupport.dispatchMethod(DispatchActionSupport.java:327)rnat com.hollycrm.springframework.web.struts.DispatchActionSupport.execute(DispatchActionSupport.java:226)rnat org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)rnat org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)rnat org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)rnat org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)rnat javax.servlet.http.HttpServlet.service(HttpServlet.java:709)rnat javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)rnat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)rnat com.hollycrm.springframework.web.filter.RequestEncodeFilter.doFilter(RequestEncodeFilter.java:46)rnat org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)rnat org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)rnat org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)rnat org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)rnat org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)rnat org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)rnat org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)rnat org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)rnat org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)rnat org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)rnat org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)rnat org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)rnat org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)rnat java.lang.Thread.run(Thread.java:534)rnCaused by: javax.transaction.RollbackExceptionrnat org.objectweb.jotm.TransactionImpl.commit(TransactionImpl.java:228)rnat org.objectweb.jotm.Current.commit(Current.java:475)rnat net.sf.hibernate.transaction.JTATransaction.commit(JTATransaction.java:56)rn... 37 morernrn页面有时出500 显示:rnHTTP Status 500 - Dispatch[/monitor] to method totalSheetMonitor returned an exceptionrnrn--------------------------------------------------------------------------------rnrntype Status reportrnrnmessage Dispatch[/monitor] to method totalSheetMonitor returned an exceptionrnrndescription The server encountered an internal error (Dispatch[/monitor] to method totalSheetMonitor returned an exception) that prevented it from fulfilling this request.rnrnrn--------------------------------------------------------------------------------rnrnApache Tomcat/5.5.9
使用Hibernate分页问题
使用hibernate调用自己的分页类 第一页数据出来了 但是没有下一页的数据 页码也没有 走断点总记录数和页码的分组数都计算出来了rn这是分页类rnpackage cn.jbit.renting.bean;rnrnrnrnimport java.io.Serializable;rnimport java.util.ArrayList;rnimport java.util.List;rnrn/**rn * Java Beanrn * @author Administratorrn *rn */rnpublic class Pager implements Serializablern rn //public static final int PAGE_RECORD = 6;rn public static final int GROUP_RECORD = 5;//显示几组rn public static int page_record;//每页显示几条数据rn private int currentPage; // 当前页码rn private int pageCount; // 总页数rn private int recordCount; // 总记录数rn rn private int currentGroup; // 当前组数rn private int groupCount; // 总组数rn private List groupList; // 页面中需要的分组页索引rn public int prevPage;rn public int nextPage;rn rn public int getPage_record() rn return page_record;rn rnrn public void setPage_record(int page_record) rn this.page_record = page_record;rn rnrn // 构造函数rn public Pager(int page)rn currentPage = page;rn rn rn // 获取当前页页码rn public int getCurrentPage()rn return currentPage;rn rn rn // 获取下一页页码rn public int getNextPage()rn if(currentPage < pageCount)rn return currentPage+1;rn elsern return pageCount;rn rn // 获取上一页页码rn public int getPrevPage()rn if(currentPage <= 1)rn return 1;rn elsern return currentPage - 1;rn rn rn // 获取当前组数rn public int getCurrentGroup()rn return currentGroup;rn rn rn public List getGroupList()rn // 计算当前组数rn currentGroup = (int)Math.ceil((float)currentPage / GROUP_RECORD);rn rn groupList = new ArrayList();rn int start = (currentGroup-1) * GROUP_RECORD;rn int end = (start + GROUP_RECORD) < pageCount ? start + GROUP_RECORD : pageCount;rn for (int i = start + 1; i <= end; i++) rn groupList.add(i);rn rn return groupList;rn rn rn rn // 获取总页数rn public int getPageCount()rn return pageCount;rn rn rn // 设置总记录数rn public void setRecordCount(int recordCount) rn this.recordCount = recordCount;rn pageCount = (int)Math.ceil(((float)recordCount / page_record));rn rn rn // 获取总记录数rn public int getRecordCount() rn return recordCount;rn rnrnrnrnrnrn方法调用rn/***rn * 分页rn */rn public List SearchpageHouse(Pager pager) rn if(pager.getRecordCount() == 0)rn pager.setRecordCount(getHouse().size());//总共多少条记录rn rn String hql="from House";rn rn Query query=session.createQuery(hql);rn int start=(pager.getCurrentPage() - 1) * Pager.page_record;//起始位置rn query.setFirstResult(start);rn query.setMaxResults(start + Pager.page_record);//结束为止rn rn List list=query.list();rn return list;rn rn rnrnrnrnrnservlet里的调用rn public void doPost(HttpServletRequest request, HttpServletResponse response)rn throws ServletException, IOException rnrn response.setContentType("text/html;UTF-8");rn response.setCharacterEncoding("UTF-8");rn request.setCharacterEncoding("UTF-8");rn PrintWriter out = response.getWriter();rn// HouseBiz house=new HouseBizImpl();rn// List houses=house.getHouse();rn// request.setAttribute("houses", houses);rn// request.getRequestDispatcher("MyJsp.jsp").forward(request, response);rn HouseBiz hb=new HouseBizImpl();rn String page=request.getParameter("page");rn int p=1;rn if(page!=null&&!(page.equals("")))rn rn p=Integer.parseInt(page);rn rn Pager pager=new Pager(p);rn pager.setPage_record(3);//每页显示三条记录rn rn //int size=2;rn //List list=hb.getpageHouse(index, size);rn List list=hb.SearchpageHouse(pager);rn// int count=hb.getHouse().size();rn// int topage=(count%size==0)?(count/size):(count/size+1);rn //request.setAttribute("topage", topage);//最大页码rn request.setAttribute("houses", list);rn //request.setAttribute("index", index);//当前页码rn request.setAttribute("paper", pager);rn request.getRequestDispatcher("MyJsp.jsp").forward(request, response);rn rnjsp页面rnrnrnrnrn rn rn rn rn rn $houses.titlern 修改rn 删除rn rn rn rn rn $houses.street_id.name--$houses.street_id.distrct_ID.namern rn rn 联系电话:$houses.contactrn rn rn rn rn rn 上一页rn rn rn $irn rn rn $i rn rn rn 下一页rn rn
hibernate分页问题!
给STRUTS SPRING HIBERNATE做的一个简单分页rn一开始能行rn为什么多点几次就会被卡住在执行查询语句中呢 ? rnLOG4J显示到这: rnabout to open PreparedStatement (open PreparedStatements: 0, globally: 0) rn- opening JDBC connectionrn是连接池的问题吗?rn下面是代码: rn-------------------得到记录条数------------------------rnString hql = "select count(*) from Jobs"; rncounter = ((Integer)this.getHibernateTemplate().iterate(hql).next()).intValue(); rnrnrn-------------------查询数据----------------------------rnString hql = "from Jobs where " + scope +" order by job_id desc"; rn Query q = this.getSession().createQuery(hql); rn q.setFirstResult(startRow); rn q.setMaxResults(pageSize); rn List list = q.list(); rn this.getSession().close();
hibernate分页奇怪问题
今天在做hibernate分页时遇到一个奇怪的问题,我在一的一端加载数据能够在Web端显示出来rn 调用的方法rn public List getTestClassList(int pagesize,int currow) rn log.debug("get page data");rn List vehicleList = null;rn Session session = this.getSession();rn Transaction transaction= session.beginTransaction();rn tryrn Query q=session.createQuery("from TestClass");rn q.setFirstResult(currow);rn q.setMaxResults(pagesize);rn vehicleList=q.list();rn session.flush();rn return vehicleList;rn catch(RuntimeException re)rn log.error("get page data failed", re);rn throw re;rn finallyrn transaction.commit();rn session.close();rn rn rnrn但是在多的一端加载数据时也调用相同的方法,把TestClass换成多的一端的实体类进行调用,结果能显示出调用的sqlrn但是却抱了一个错误rn[ERROR] 2009-03-21 04:19:29 org.hibernate.LazyInitializationException - could not initialize proxy - the owning Session was closedrnorg.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closedrn为什么加载一的一端可以显示出来,调用多的一端就不能显示出来了。而且我在多的一端也加了lazy=false属性。
相关热词 c++和c#哪个就业率高 c# 批量动态创建控件 c# 模块和程序集的区别 c# gmap 截图 c# 验证码图片生成类 c# 再次尝试 连接失败 c#开发编写规范 c# 压缩图片好麻烦 c#计算数组中的平均值 c#获取路由参数