-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: after update the result show in the page haven't updated yet
PostPosted: Thu Jun 10, 2004 10:36 pm 
Newbie

Joined: Thu Jun 10, 2004 1:01 pm
Posts: 1
page1.jsp list all information of a table
the scripts are as follow:
<%
Query paperQuery = hisession.createQuery("select paper from Paper paper");
Iterator iterator = paperQuery.iterate();
while(iterator.hasNext()) {
Paper tempPaper = (Paper)iterator.next();
//...
}
%>

page2.jsp,update a row of the table,as follows:
<%
net.sf.hibernate.Session hisession = HibernateUtil.currentSession();
java.util.List paperList = hisession.find("select paper from Paper paper where paper.id=" + Util.getRequestInt(request,"paperid"));
Paper thepaper = (Paper)paperList.get(0);
thepaper.setHitcounts(thepaper.getHitcounts() + 1);
hisession.save(thepaper);
hisession.flush();
%>

page2 and write database successfully,but when I return to page1 and flush,the infomation may keep the same! Keep flushing it is possible to see updated infomation and but not sure,it may even show the information before updated.

I observed if table paper has two columns:
id,hitcounts
and id is the primary key.
at first there is a row(1,10),pape1.jsp show the column correctly.
when pape2.jsp is executed the database has been updated to (1,11),
if pape2.jsp is executed one more time,the database has been updated to (1,12).
If now pape1.jsp is executed,the above three possible results may be shown,what is want is the last one!!
Notice I've called Session.flush() after update in page2.jsp.
What's the problem????

Can you help me,please!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.