-->
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.  [ 7 posts ] 
Author Message
 Post subject: Why Hibernate Transaction in a query ?
PostPosted: Tue Mar 09, 2004 4:07 am 
Beginner
Beginner

Joined: Wed Mar 03, 2004 6:02 am
Posts: 46
Location: Kuala Lumpur, Malaysia
In the sample code within the documentation @ hibernate.org; it uses Hibernate Transactions although the method only does a select query. Why is that needed since it is not making any changes to the DB ?

Thanks

Regards,

alistair


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 6:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You should always use a transaction, always. There is in fact no such thing as "no transaction". Transactions are needed for correct transaction isolation. Search the forum, this has been discussed multiple times already.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 3:12 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
michael wrote:
You should always use a transaction, always. There is in fact no such thing as "no transaction". Transactions are needed for correct transaction isolation. Search the forum, this has been discussed multiple times already.

Well I would be a little bit more strict. There are specific cases where tx are not needed.
But unless you don't know what you do, use tx, it's you friend.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 3:30 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
The reason you need a transaction when querying is that if you do multiple queries, you want to be querying consistent data. You wouldn't want the data changing underneath you from query to query. Using a transaction ensures that a set of related queries will be querying consistent data.

I think my role on these forums is to provide more straightforward answers where the forum long-timers tend to be astoundingly terse. Of course, by the time I've answered as many thousands of posts FOR FREE as they have, I'll probably be worn down to a point of similar terseness :-D

Cheers!
Rob


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 9:53 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 6:02 am
Posts: 46
Location: Kuala Lumpur, Malaysia
Thank you for all your comments. I'll look for more details in the archives.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 4:09 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
[quote="RobJellinghaus"tend to be astoundingly terse[/quote]
I'm offensed ;-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 5:08 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
emmanuel wrote:
I'm offensed ;-)

Yeah, you look pretty offensed :-D
Cheers!
Rob


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.