【发布时间】:2011-01-03 13:19:58
【问题描述】:
有没有出现hibernate无法关闭打开的连接???
我正在使用 Hibernate 3.2.5 和 Oracle 10g express 开发一个 JSF 2.0 应用程序。经过固定数量的事务后,hibernate 可以不连接到数据库,甚至我也无法使用 sqlDeveloper 连接。正如我所检查的,在此失败之前的事务数几乎等于 init.ora 中的 进程 的数量>.
我总是使用这样的休眠会话:
try {
session.beginTransaction();
...
} catch (Exception ex) {
Transaction tx = session.getTransaction();
if (tx.isActive()) {
tx.rollback();
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, ex.getMessage(), ex.getMessage()));
}
} finally {
session.close();
}
我的休眠配置
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.OracleDialect</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property>
<property name="hibernate.connection.username">CUSTOMS_G2G</property>
<property name="hibernate.connection.password">123456</property>
<mapping resource="ir/khorasancustoms/g2g/persistance/UserGroup.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/User.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/CatalogGroup.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/CatalogValue.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/gates/Receipt.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/gates/Price.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/gates/Promise.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/gates/Exit.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/gates/Weight.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/gates/Fee.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/Page.hbm.xml"/>
<mapping resource="ir/khorasancustoms/g2g/persistance/Permission.hbm.xml"/>
</session-factory>
</hibernate-configuration>
【问题讨论】: