-->
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.  [ 3 posts ] 
Author Message
 Post subject: What happens with Queries executed without transaction?
PostPosted: Sat May 21, 2011 10:53 am 
Beginner
Beginner

Joined: Tue Jul 03, 2007 8:47 am
Posts: 46
Hi,

I am currently maintaining an application, which does hibernate queries without an active (manually managed) transaction,
only for data modifications it creates a transaction.
This seems to work well, however I remember somewhere I've read that hibernate always requires a transaction.
What are the implications of ignoring this rule?

It seems for this case the postgresql driver (or hibernate?) opens up a hidden transaction which is kept open indefinetly,
and never commits. (most likely rolls back when the app closes).

Thank you in advance, Clemens


Top
 Profile  
 
 Post subject: Re: What happens with Queries executed without transaction?
PostPosted: Sun May 22, 2011 4:38 am 
Newbie

Joined: Tue Jul 20, 2010 1:53 am
Posts: 18
When we go for Single(using methods like save(),delete(),persist() . . ) row operations in Hibernate .

compulsory we need transaction in particular database to transform our into database from Configuration file. And we need save our data into Database it'srequired to commit the transaction into Database otherwise it won't save , just effect only[b][/b].


Top
 Profile  
 
 Post subject: Re: What happens with Queries executed without transaction?
PostPosted: Sun May 22, 2011 7:41 am 
Beginner
Beginner

Joined: Tue Jul 03, 2007 8:47 am
Posts: 46
Sorry, but that is not an answer to my question.

When accessing the database without an active transaction (so read-only access), somewhere somebody creates a Transaction in the background even if the jdbc connection is not in auto-commit mode. In my case there seems a long-running transaction which is never commited responsible for loading entities that are accessed when no explicit transaction was going on.
My question was about who is responsible for this, and wether the behaviour could be changed.

Code:
Session session = factory.openSession();

//Under which transaction is this query executed?
session.get(SomeEntity.class, 2);


Thanks, Clemens


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