-->
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: stale data
PostPosted: Sun Jul 27, 2008 5:19 pm 
Newbie

Joined: Fri Aug 11, 2006 8:45 am
Posts: 1
Location: Atlanta, GA
I've got an interesting problem w/ my webapp displaying stale data on a page refresh.

I've done a lot of searching and have found what looks like correct answers, but nothing has worked.

I'm making ajax calls to update some objects, but when I refresh the page (or go back and enter through the action) I do not always see the changes. I can see them in the database of course.

Any help will be much appreciated.

The Hibernate classes are in a jar sitting inside JBoss. The webapp is in a .war inside JBoss (not my decision), and I'm using JNDI for the datasource.

The save method is as follows :
Code:
   public void updateAGroupDefinition(GroupDefinition groupDefinitionToUpdate)
   {
      Transaction tx = null;
      try
      {
         tx = HibernateSessionFactory.getSession().beginTransaction();
         this.groupDefinitionDAO.attachDirty(groupDefinitionToUpdate);
         tx.commit();
         HibernateSessionFactory.getSession().flush();
      }
      catch (Exception e)
      {
         tx.rollback();
         e.printStackTrace();
         throw new RuntimeException(e.getMessage());
      }
      finally
      {
         HibernateSessionFactory.getSession().flush();
         HibernateSessionFactory.getSession().close();
      }
   }


The dao method (MyEclipse generated and not my code) being called is :
Code:
   public void attachDirty(GroupDefinition instance) {
      log.debug("attaching dirty GroupDefinition instance");
      try {
         getSession().saveOrUpdate(instance);
         log.debug("attach successful");
      } catch (RuntimeException re) {
         log.error("attach failed", re);
         throw re;
      }
   }


The read method is :
Code:
      try
      {
         String queryString = "from ExtCustomerCodeDefinition as model where model.code = ? and model.delete = 'N'";
         Session sess = getFreshSession();
         sess.setFlushMode(FlushMode.ALWAYS);
         Query queryObject = sess.createQuery(queryString);
         queryObject.setParameter(0, codeToFind);
         System.out.println(queryObject.getQueryString());
         
         ExtCustomerCodeDefinition retVal = (ExtCustomerCodeDefinition) queryObject.list().get(0);
         log.debug("Found : " + retVal);
         try
         {
            ExtGroupDefinition topGroup = retVal.getTopGroup();
            log.debug("\t" + topGroup);
            if(topGroup.getGroups() != null)
            {
               for(ExtGroupDefinition childGroup : topGroup.getGroups())
               {
                  log.debug("\t" + childGroup);
               }
            }
         }
         catch (NoHierarchyException e)
         {
            log.debug("\t With no top group");
         }
         
         return retVal;


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.