-->
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: Session is closed Automatically when i tx.Commit()
PostPosted: Mon Feb 12, 2007 12:13 pm 
Newbie

Joined: Thu Mar 24, 2005 10:07 am
Posts: 14
Can anyone tell me where I can find the setting to enable / disable session close on TX commit. I'm using JTA, jboss and hibernate 3.2.

Startup Logs:
Code:
[SettingsFactory] Automatic flush during beforeCompletion(): enabled
[b][SettingsFactory] Automatic session close at end of transaction: enabled[/b]
[SettingsFactory] Scrollable result sets: enabled
[SettingsFactory] JDBC3 getGeneratedKeys(): enabled
[SettingsFactory] Connection release mode: after_statement
[SettingsFactory] Default batch fetch size: 1
[SettingsFactory] Generate SQL with comments: disabled
[SettingsFactory] Order SQL updates by primary key: disabled
[SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory


Hibernate version:
3.2

Mapping documents: N/A

Code between sessionFactory.openSession() and session.close(): N/A
session.close() throws exception

Full stack trace of any exception that occurs:
Code:
Session was already closed


Name and version of the database you are using: N/A


The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 12, 2007 1:15 pm 
Newbie

Joined: Fri Aug 04, 2006 3:01 pm
Posts: 13
See http://www.hibernate.org/hib_docs/v3/ap ... SE_SESSION

Don't forget to vote !


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 12, 2007 1:34 pm 
Newbie

Joined: Thu Mar 24, 2005 10:07 am
Posts: 14
Im using a hibernate service to create my session factory. No matter where i put this setting it doesnt take effect.

Ive put it in hibernate.properties and my hbm.xml. and its always set to enabled.

How do i change it to false.. and why is it set to true.. seems like a silly assumption, since most db providers tell you to close your session with the db in every finally block.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 14, 2007 12:30 am 
Expert
Expert

Joined: Tue Jan 30, 2007 12:45 am
Posts: 283
Location: India
Hi jimithang3,

if you are using auto close =true then you need not to close session explicitly .Even if you are using Spring the You could use AOP for automated Transactional handling.

_________________
Dharmendra Pandey


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 14, 2007 9:55 am 
Newbie

Joined: Thu Mar 24, 2005 10:07 am
Posts: 14
I resolved the issue, it turned out to be kinda tricky, at least to me so heres the fix incase anyone else had the same problems.

I deployed my data access code as a hibernate HAR file. The har mbean descriptor doesn't have a setting to toggle the AUTO_SESSION_CLOSE.
So naturally I didn't have a session.close() in my finally blocks. Under heavy load the transactions started committing 2x and the system would become unstable until JTA expired the failed transactions.

To fix I deployed data access code as a SAR file with a HibernateService descriptor which provides access to the AUTO_SESSION_CLOSE, which is now disabled and im closing every connection manually in the finally blocks.


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.