-->
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: No db connection close after select exception?
PostPosted: Wed Mar 15, 2006 2:01 pm 
Regular
Regular

Joined: Wed Mar 15, 2006 1:48 pm
Posts: 91
I am using hibernate 3.0.5 with Spring framework (version 1.2.6). When there is an exception in select statement, it seems hibernate doesn't close connection so other codes can't open it and finally times out. In source code for hibernate, I find EntityDeleteAction, EntityInsertAction etc, but can't find EntitySelectAction.java. Where is the code to hanlde select action and how it handles the db connection issue when there is an exception in this case? Thanks!


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0.5
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
Oracle 9.2.0.4
The generated SQL (show_sql=true):
could not execute query; bad SQL grammar [

select devicealar0_.PANEL_DEVICE_ALARM_ID as PANEL1_, devicealar0_.PANEL_DEVICE_ID as PANEL2_15_, devicealar0_.ALARM_EVENT_CA

T_ID as ALARM3_15_, devicealar0_.TEMPLATE_ID as TEMPLATE4_15_, devicealar0_.EVENT_OCCURENCE_ID as EVENT5_15_, devicealar0_.AL

ARM_DATE as ALARM6_15_, devicealar0_.PANEL_ID as PANEL7_15_, devicealar0_.SITE_ID as SITE8_15_, devicealar0_.EVENT_ID as EVEN

T9_15_, devicealar0_.STATUS as STATUS15_, devicealar0_.STATUS_UPDATED_BY as STATUS11_15_, devicealar0_.STATUS_DATE as STATUS1

2_15_, devicealar0_.REFERENCE_ID as REFERENCE13_15_ from PANEL_DEVICE_ALARMS devicealar0_ where devicealar0_.SITE_ID=? and de

vicealar0_.PANEL_ID=? and devicealar0_.PANEL_DEVICE_ID=? and devicealar0_.EVENT_ID=? and (devicealar0_.STATUS in (? , ? , ?))

];

nested exception is java.sql.SQLException: ORA-00932: inconsistent datatypes: expected NUMBER got BINARY

,numValue=<null>,dateValue=<null>]


Debug level Hibernate log excerpt:

[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 15, 2006 8:28 pm 
Regular
Regular

Joined: Thu May 26, 2005 12:20 am
Posts: 72
Are you handling the exception in such a way as to still allow session.close() to be called?

what is the "Code between sessionFactory.openSession() and session.close():"?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 12:37 am 
Newbie

Joined: Mon Jun 06, 2005 10:11 am
Posts: 14
Are you doing session.close in finally block?

/Ashwani


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 12:46 pm 
Regular
Regular

Joined: Wed Mar 15, 2006 1:48 pm
Posts: 91
I never call openSession in my code, Spring will handle it. Normally code is like this in structure,

--------------------------
final Query query = getSession().createQuery(GET_LATEST_ROLLING_PERIOD);

final List<PanelDeviceRollingPeriod> results = query.list();

return results;
---------------------------

So do I need add close sessoin explicitly in code?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 1:15 pm 
Regular
Regular

Joined: Thu May 26, 2005 12:20 am
Posts: 72
Which session pattern are you using in Spring? (How does Spring open/close the sessions for you?)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 1:47 pm 
Regular
Regular

Joined: Wed Mar 15, 2006 1:48 pm
Posts: 91
I don't know yer. I went through spring related code, but failed to find how it handles sql exception and related session behaviour. I went to hibernate code and I did find it close conneciton and throws hibernateexception if there is a sqlexception. I have posted an article in spring forum for how handling hibernateexception in spring. Let us wait to see. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 16, 2006 3:29 pm 
Regular
Regular

Joined: Thu May 26, 2005 12:20 am
Posts: 72
Yes, this is probably more appropriate in the Spring forum. I am also using Spring with hibernate, but there are different patterns for how you can handle sessions. (i.e. SessionInView filter) Different patterns would handle it differently. Good luck!


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.