Visual Paradigm Logo
     Build Quality Applications Faster, Better and Cheaper
 
Home | Products | Download | Documentation | Support | Resources | Partners | Quick Tour | Shop | Company |  
 
   Visual Paradigm Discussion Forum
  Login   [ Register ] Email: Password: Log me on automatically I lost my password  
Advanced Search
getting mixed new/old data when refreshing page  
Forum Index -> DB Visual ARCHITECT (DB-VA)
Author Message
Atmospherian


Joined: 2007/05/17
Messages: 4

Offline

i have a web app that reads in objects from the db, allows the users to make changes, inserts, etc. and all that works fine. the problem is, sometimes, the old values of the modified objects appear, and sometimes they do not. if i refresh the page over and over again i can see the new and old values showing up randomly.

the only way to fix this so far has been to redeploy my application to the server. invalidating the users session does not work, i tried using .evict(object), but that didnt work either (maybe im not using it at the right time, i tried using it after the .save(), and the .commit() of the object and the transaction and that had no effect.)

i understand that hibernate does some caching to minimize the amount of queries it executes, but does that explain why the new AND old data are showing up randomly?
 
Jick


Joined: 2005/04/29
Messages: 2881

Offline

Hello Atmospherian,

I will discuss with our engineers and come back to you.

Best regards,
Jick

Visual Paradigm International Ltd.
http://www.visual-paradigm.com

Build Quality Applications Faster, Better and Cheaper
 
Jick


Joined: 2005/04/29
Messages: 2881

Offline

Hello Atmospherian,

Please answer the following questions:

1. Which kind of code are you implementing? Java or .NET
2. Which kind of Persistent API did you choose? (e.g. POJO, Factory, DAO and etc.)
3. Which kind of WebServer are you using? What version is it?
4. Which kind of database are you using? (e.g. MySQL, Oracle, MSSQL...).
5. Which kind of Mapping type (XML/Annotation) did you choose? (for Java orm only)

Is it possible to send us your project file to have a look? If possible, I suggest you send me your project through E-mail. My E-mail address is:
jick@visual-paradigm.com

Best regards,
Jick

Visual Paradigm International Ltd.
http://www.visual-paradigm.com

Build Quality Applications Faster, Better and Cheaper
 
christine.slotty


Joined: 2007/03/02
Messages: 8

Offline

Hi Atmospherian,

I have had the same problem as you! I also noticed that "evict" wouldn't work, and I used to get the absolute same effect as you (having old and new data show up randomly).

This is what helped me:

Whenever I want to change data I follow these steps:
- save a name or id of the object I want to change, so I can identify it later (for a new object this isn't necessary)
- start a new transaction
- make the changes
- object.save()
- commit(), flush()
- close and reopen the session!
- reload the object by f.ex. looking up the id or the name and loading it into the session the usual way, so that the object will be reloaded into the hibernate session.

Like I said, evict just doesn't do what it's supposed to do. At least for me, whereas I must say that I still might have some configuration problem, as commited and flushed changes aren't reflected in the database, until I stop my app server (WASCE). But at least I have changes reflected in my web app, by now.

Closing and re-opening the session looks like this:

ProjectNamePersistentManager.instance().getSession().close();
ProjectNamePersistentManager.instance().getSession();

HTH
Christine
 
christine.slotty


Joined: 2007/03/02
Messages: 8

Offline

Oh, one more thing: Additionally, I guess you should turn off browser caching. I have these lines in my JSP/HTML header:

<meta http-equiv="cache-control" content="no-cache,must-revalidate">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
 
Atmospherian


Joined: 2007/05/17
Messages: 4

Offline

christine.slotty wrote:
Oh, one more thing: Additionally, I guess you should turn off browser caching. I have these lines in my JSP/HTML header:

<meta http-equiv="cache-control" content="no-cache,must-revalidate">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
 


Hey Christine,

thanks for your replies, i will definitely try out your suggestions and see if they help.

Atmospherian
 
Atmospherian


Joined: 2007/05/17
Messages: 4

Offline

Jick wrote:
Hello Atmospherian,

Please answer the following questions:

1. Which kind of code are you implementing? Java or .NET
Java
2. Which kind of Persistent API did you choose? (e.g. POJO, Factory, DAO and
etc.)
Factory
3. Which kind of WebServer are you using? What version is it?
tried with Glassfish v1 and v2 beta, and JBoss 4.0.5 and 4.2
4. Which kind of database are you using? (e.g. MySQL, Oracle, MSSQL...).
MySQL 5
5. Which kind of Mapping type (XML/Annotation) did you choose? (for Java orm only) XML mapping

Is it possible to send us your project file to have a look? If possible, I suggest you send me your project through E-mail. My E-mail address is:
jick@visual-paradigm.com

Best regards,
Jick 
 
Jick


Joined: 2005/04/29
Messages: 2881

Offline

Hi Atmospherian,

Sorry, I didn't aware the above post has your reply included. I just spotted and asking our engineers for more details.

Best regards,
Jick

Visual Paradigm International Ltd.
http://www.visual-paradigm.com

Build Quality Applications Faster, Better and Cheaper
 
Jick


Joined: 2005/04/29
Messages: 2881

Offline

HI Atmospherian,

We guess that you haven't close the session at the end of the request, which caused the old value to be cached in the old sessions.

Best regards,
Jick

Visual Paradigm International Ltd.
http://www.visual-paradigm.com

Build Quality Applications Faster, Better and Cheaper
 
 
   Forum Index -> DB Visual ARCHITECT (DB-VA)
Go to:   
Powered by JForum 2.1.4 © 2005 - Rafael Steil