-->
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: Deleting problem
PostPosted: Mon Jul 31, 2006 8:53 am 
Newbie

Joined: Tue Jul 25, 2006 5:04 am
Posts: 4
Hi friends,
i have some problems about deleting records from database by hibernate. Here is the problem: when i delete records by hibernate everything is all right; the record is deleted from database but after deleting the record if i want to get all records, the record deleted before comes with other records( but this record isnt in the database)

I think i have caching problems but can not solve it. Is there anyone having the solution?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 31, 2006 5:38 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Have you committed the transaction that did the delete? If you flushed the session then you'll see the delete, but until you commit the transaction, only that one connection sees the delete. You have to commit it.

Afaik Hibernate doesn't have any issues regarding finding deleted items in its cache.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 3:11 am 
Newbie

Joined: Tue Jul 25, 2006 5:04 am
Posts: 4
this is a web project and i have a filter, and i do those things in doFilter{} method...

chain.doFilter(request, response);
Session.openSession().flush();
Session.openSession().connection().commit();
Session.commitTransaction();


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 5:39 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Why are you committing the connection? That'll work while you're using just JDBC transactions, but if you switch to distributed transactions, it'll cause problems. You should get the correct transaction object and commit that.

I have no idea what Session.commitTransaction() does, as it's not part of hibernate or JDBC.

However, this isn't going to solve your problem. You should read up on the correct way to use transactions and hibernate. Chapters 2, 3 and 19 of the refdocs might help.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 5:30 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Why are you committing the connection? That'll work while you're using just JDBC transactions, but if you switch to distributed transactions, it'll cause problems. You should get the correct transaction object and commit that.

I have no idea what Session.commitTransaction() does, as it's not part of hibernate or JDBC.

However, this isn't going to solve your problem. You should read up on the correct way to use transactions and hibernate. Chapters 2, 3 and 19 of the refdocs might help.

_________________
Code tags are your friend. Know them and use them.


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.