-->
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: Problem closing oracle session with hibernate 4.1.8
PostPosted: Wed Dec 19, 2012 6:11 am 
Newbie

Joined: Wed Dec 19, 2012 5:36 am
Posts: 2
I'm using hibernate and oracle 11g2 in one of my projects. I had to upgrade recently to a new version of hibernate, first from 3.6.1 to 3.6.10 and then to 4.1.8. However after migrating to 4.1.8 now my oracle sessions are never closed even after I close SessionFactory and I don't understand why.

Below you can find an example of how I'm creating and closing the session factory:

- Using hibernate 3.6.10:
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.openSession();
Journal t = (Journal) session.get(Journal.class, 12);
session.close();
sessionFactory.close();

- Using hibernate 4.1.8:
Configuration configuration = new Configuration();
configuration.configure();
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().
applySettings(configuration.getProperties()).
buildServiceRegistry();
SessionFactory sessionFactory = configuration.buildSessionFactory(serviceRegistry);
Session session = sessionFactory.openSession();
Journal t = (Journal) session.get(Journal.class, 12);
session.close();
sessionFactory.close();

- The hibernate.cfg.xml is:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@....</property>

<property name="hibernate.default_schema">xx</property>
<property name="hibernate.connection.username">yy</property>
<property name="hibernate.connection.password">zz</property>

<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>

<mapping resource="Journal.hbm.xml" />
</session-factory>
</hibernate-configuration>

After the upgrade to 4.1.8 all oracle sessions are never closed... I usually run the following select statement to check which are the open connections:
- select status, logon_time, SID, Serial#, UserName, SchemaName, Program, Machine from v$session;

Please can anyone give me any insight on how to fix this?

Many thanks in advance.


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.