-->
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: Hibern8IDE: problem with closing sessions on error
PostPosted: Tue Feb 17, 2004 4:42 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
I am having a problem with Hibern8IDE where, if I get some syntax error in the HQL, I seem to have to restart Hibern8IDE in order to do more work. Looking at the code, I see that when an error occurs, the session for the page is released.

The example is:

Run a HQL query with a syntax problem, and get:

Code:
Hibernate: select physicianp0_.procedureTypeId as x0_0_, physicianp0_.staffId as x1_0_, max(physicianp0_.effectiveDate) as x2_0_ from PhysicianPreferenceCard physicianp0_ where (physicianp0_.procedureTypeId=248 )and(physicianp0_.effectiveDate<='01/31/2004' ) group by  physicianp0_.procedureTypeId , physicianp0_.staffId
released session
Hibernate: select physicianp0_.procedureTypeId as x0_0_, physicianp0_.staffId as x1_0_, max(physicianp0_.effectiveDate) as x2_0_ from PhysicianPreferenceCard physicianp0_ where (physicianp0_.procedureTypeId=248 )and(physicianp0_.effectiveDate<='01/31/2004' ) group by  physicianp0_.procedureTypeId , physicianp0_.staffId , xxx
12:07:03,593  WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: 42703
12:07:03,593 ERROR JDBCExceptionReporter:46 - ERROR: column "xxx" does not exist

12:07:03,593  WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: 42703
12:07:03,593 ERROR JDBCExceptionReporter:46 - ERROR: column "xxx" does not exist

12:07:03,609 ERROR JDBCExceptionReporter:38 - Could not execute query
org.postgresql.util.PSQLException: ERROR: column "xxx" does not exist


If I now fix the HQL, so that it is correct, and rerun the query, I get:

Code:
Hibernate: select physicianp0_.procedureTypeId as x0_0_, physicianp0_.staffId as x1_0_, max(physicianp0_.effectiveDate) as x2_0_ from PhysicianPreferenceCard physicianp0_ where (physicianp0_.procedureTypeId=248 )and(physicianp0_.effectiveDate<='01/31/2004' ) group by  physicianp0_.procedureTypeId , physicianp0_.staffId
12:39:21,578  WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: 25P02
12:39:21,578 ERROR JDBCExceptionReporter:46 - ERROR: current transaction is aborted, commands ignored until end of transaction block

12:39:21,578  WARN JDBCExceptionReporter:38 - SQL Error: 0, SQLState: 25P02
12:39:21,578 ERROR JDBCExceptionReporter:46 - ERROR: current transaction is aborted, commands ignored until end of transaction block

12:39:21,578 ERROR JDBCExceptionReporter:38 - Could not execute query
org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block

   at org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139)
   at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:154)
   at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:101)
   at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43)
   at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:515)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:50)
   at org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:231)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:83)
   at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:794)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:188)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:949)
   at net.sf.hibernate.loader.Loader.list(Loader.java:940)
   at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:833)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1475)
   at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
   at net.sf.hibern8ide.HQLQueryPage.getList(HQLQueryPage.java:25)
   at net.sf.hibern8ide.Hibern8IDE$9.contentsChanged(Hibern8IDE.java:719)
   at net.sf.hibern8ide.Hibern8IDE$9.intervalAdded(Hibern8IDE.java:679)
   at javax.swing.AbstractListModel.fireIntervalAdded(AbstractListModel.java:130)
   at net.sf.hibern8ide.QueryPageModel.add(QueryPageModel.java:44)
   at net.sf.hibern8ide.Hibern8IDE$ExecuteQuery.actionPerformed(Hibern8IDE.java:878)
   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1767)


Running any other queries gets the same problem.


Any ideas?


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2004 5:40 pm 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
Additionally, I am seeing some strange things in the log:

12:51:44,562 WARN SessionImpl:3358 - unclosed connection

12:54:13,421 WARN SessionImpl:3355 - finalizing unclosed session with closed connection


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2004 2:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes - I know there is some bugs regarding proper error handling of the session when certain errors occur :(

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 2:07 am 
Senior
Senior

Joined: Tue Nov 25, 2003 9:35 am
Posts: 194
Location: San Francisco
What seems to improve things is to make the session a non-final instance variable on AbstractQueryPage, and set the session to null in the release(), ie.

Code:
    public void release() {
       if (!released && session.isOpen()) {
          try {
             session.flush();
             session.close();
          } catch (Exception e) {
             exceptions.add(e);
          }
          released = true;
          session = null;
       }
   
    }


Max, does this work for you? If so, should I put this in JIRA or somewhere else?


Sherman


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 3:53 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
put it in the jira so it won't be lost....

...but i don't nulling it is the way to go ;)

_________________
Max
Don't forget to rate


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.