-->
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.  [ 1 post ] 
Author Message
 Post subject: HibernateContext needs to close session?
PostPosted: Fri Nov 05, 2004 10:44 pm 
Newbie

Joined: Fri Nov 05, 2004 2:03 pm
Posts: 1
Hibernate version: JBoss4.0

I use HibernaetContext.getSession(JNDI) within a stateless session bean in JBoss4 like this:
Code:
public void callMethod() {
  Session session = HibernaetContext.getSession(JNDI);
  try {
    Transaction tx = session.beginSession();
    // do  something with session
    tx.commit();
  } catch(HibernaetException e) {
  } finally {
    if(session!=null) {
      session.close();
    }
  }
}

After I call this method, JBoss show the warning: Session is closed
And if I marked up the finally part, it is still working without no warning message.
Do I need to close session when using HibernateContext.getSession() or just leave the close jobs to JBoss JXA Manager?

One more question: I use Oracle for DB and configure oracle-ds.xml by the sample in JBoss, but when the system idles for sometime and I call the method again, the connection seems hanging for a long time and it shows "connection reset", "Destroying connection that could not be successfully matched"

Are there any configurations I miss, or what can I do to avoid these situations?

oracle-ds.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
  <local-tx-datasource>
    <jndi-name>OracleDS</jndi-name>
    <connection-url>jdbc:oracle:thin:@dbserver:1521:apmdb</connection-url>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <user-name>xxxxx</user-name>
    <password>xxxxxx</password>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
        <new-connection-sql>select 1 from dual</new-connection-sql>
        <check-valid-connection-sql>select sysdate from dual</check-valid-connection-sql>
      <metadata>
         <type-mapping>Oracle9i</type-mapping>
      </metadata>
     <min-pool-size>20</min-pool-size>
     <max-pool-size>100</max-pool-size>
    <idle-timeout-minutes>0</idle-timeout-minutes>     
  </local-tx-datasource>
</datasources>


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.