2013年12月8日星期日

spring3.1 + hibernate4.1 + struts2.3 integrated paging query error

 This post last edited by hcjlovejay on 2013-12-03 21:31:15
This is what I want to paging query code
String hql = "from User u  ORDER BY u.id";
Session session = sessionFactory.openSession();
Query query = session.createQuery(hql);

query.setFirstResult(1);
query.setMaxResults(7);

I use hibernate4, this sentence was added in hibernate.cfg.xml
false
No problem , not an error.
But when I added this in the spring when the problem comes in , applicationContext.xml is so written in
<property name="hibernateProperties">
<props>
<prop key="jdbc.use_scrollable_resultset">false</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql" >true</prop>
<!-- <prop key="hibernate.format_sql">true</prop> -->
</props>
</property>

this time when the mistake is to do the query
[http-80-3] WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: null
[http-80-3] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - forward-only result set does not support the requested operation.
[http-80-2] WARN org.hibernate.engine.jdbc.spi.SqlExceptionHelper - SQL Error: 0, SQLState: null
[http-80-2] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - forward-only result set does not support the requested operation.

like spring is not used in this configuration to me , specifically what the problem is also the god please answer .
------ Solution ---------------------------------------- ----
hibernate jdbc.use_scrollable_resultset "> false I question is this did not add it
------ For reference only - -------------------------------------
own Bangding ~ ~
- ---- For reference only ---------------------------------------
first you see the result set if there is seven .
------ For reference only -------------------------------------- -
forward-only result set does not support the requested operation - is not transactional configuration problem , or the above false try removing
------ For reference only --------------------------------------- < " solution " br> forward-only result set does not support the requested operation
- ---- For reference only ---------------------------------------
this it does not matter when I use the hibernate.cfg.xml testing is no problem
------ For reference only ----------------- ----------------------
the same, this is something added after hibernate4 , if not directly use this phrase also hibernate.cfg.xml error
------ For reference only ------------------------------------- -
I use HQL, so NA
------ For reference only ------------------------ ---------------
query.setFirstResult (1) ;/ / changed from 0 to see.
query.setMaxResults (7);

best look at how many , a good question to troubleshoot
------ For reference only ---------------------- -----------------
0 start is no problem , and now the main problem seems to be
false
added to the spring configuration file does not work
------ For reference only ------------------------- --------------
do you feel how to use this framework , I made an error , he often many- insert null id in com.mcy.bean.ChargeBean entry ; (don't flush the Session after an exception occurs)
------ For reference only ------------------ ---------------------
did you say this issue

没有评论:

发表评论