-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problem syncing with database. Caching?
PostPosted: Mon Mar 29, 2004 6:12 pm 
Newbie

Joined: Thu Mar 25, 2004 3:52 pm
Posts: 3
I have a basic Parent one to many Child relatonship. I am running my application from a servlet, with a ProposalManager which accesses my dao's.
Here is my Proposal.hbm.xml:
Code:
<bag
            name="resumes"
            lazy="true"
            inverse="true"
            cascade="delete"
        >

              <key
                  column="proposalid"
              />

              <one-to-many
                  class="Resume"
              />
        </bag>

Everything works fine (listing all the resumes in a proposal), except when I delete a resume from the proposal. I delete using ResumeManager, but when I go back to the resume listing page, sometimes the resume I just deleted will still be there. If I hit refresh over and over, sometimes the just deleted one will be there, sometimes not.
It seems that it is not checking the database every time. This is not browser caching, because I am logging the number of resumes from my ProposalManager getProposal() function.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 3:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You are mistaken. Fix the bug in your application.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 12:01 pm 
Newbie

Joined: Thu Mar 25, 2004 3:52 pm
Posts: 3
Im sure that I am mistaken. I would love to fix the bug in my application, but I am at a loss of where to look. I have spent the last 3 days working on this problem, and I don't know where else to turn.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 12:16 pm 
Beginner
Beginner

Joined: Tue Mar 16, 2004 5:15 am
Posts: 33
Try to isolate the application layer, which causes the problem. You reported that by hitting the refresh button you see the correct result some times. As long as there is no action (SQL mainly) done by hibernate during the refreshes the problem is about the next higher layer I guess.

One think that helps is to write an acceptence test for this behaviour. Try to reproduce it by a bunch of automated actions and eleminate every single piece of your application code as long as the actions break. If it breaks try to record the interactions between the elements. If the interaction is predictable try to mock it and continue removing. After eleminating all the code which is not necessary to reproduce the problem, you might be able to break the acceptence test into two and isolate the troublemaker even more.

I had a problem once. I done the same mentioned above. I copied the project the problem was related to and eleminated every bit of code which was not necessary (for example I recorded the chain of actions called and only called the actions and removed the entire velocity xwork stuff). It turned out to be related to some strange cascading effects. The whole elemination stuff took about 2 hours and I figured out two more bugs (the problem was caused by more then one method). So after I fixed the test, I added it to the test suite of the original project and fixed the problem maker.

And once you identified the layer causing the problem, you might be able to ask the responsible person/team/newgroup/forum on that. But as long as you are not using the same session (or at least clear/refresh) the objects the problem is linked to, hibernate shouldn't be the one to blame.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 2:19 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Quote:
If I hit refresh over and over, sometimes the just deleted one will be there, sometimes not.


oh oh, it seems you're using many sessions that are not closed.... have you read about threadlocal session?

Never forget that you must at least:
- know all about commit and close
- know about "non threadsafe" aspect of hibernate session, without understanding it, you will not be able to manage your data (an objects of course)
http://www.hibernate.org/43.html
- read 3 times at least the doc ;)

and if you're using bi directional associations, please, please read the wiki docs


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

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.