在Oracle中使用Hibernate / JPA关闭连接时的部分提交 [英] Partial commit when Connection close in Oracle with Hibernate/JPA

查看:480
本文介绍了在Oracle中使用Hibernate / JPA关闭连接时的部分提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这个错误发生在我们的存储空间已满并且DBA需要关闭连接时,kill活动会话,或者一些像这样的连接关闭(现在我可以知道发生了什么,他被解雇了....)

  javax.persistence.RollbackException:错误而commiting在org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)
。在com.cgmp.ValePedagioSite.comprarViagemPorPlaca(ValePedagioSite.java交易
: 473)
在sun.reflect.GeneratedMethodAccessor1719.invoke(来源不明)
处的java.lang.reflect.Method sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
。调用(Method.java:597)
(...)
产生的原因:org.hibernate.exception.JDBCConnectionException:无法插入:[com.cgmp.model.entity.PedagioPracaViagem]
在org.hibernate.exception.SQLStateConverter.convert(SQLStateConv erter.java:97)美元,org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66 B $ B)
在org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2295)
(...)
导致:java.sql.SQLRecoverableException:连接已关闭
at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3331)
at oracle.jdbc.driver.T2CConnection.prepareStatement(T2CConnection.java:47)
处oracle.jdbc.driver.T2CConnection oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3232)
。 prepareStatement(T2CConnection.java:47)
at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:213)
(...)

$ b其他实体插入时没有问题...

---编辑 - -



更多信息

配置c3p0

 < Resource auth =Conta iner
description =
driverClass =oracle.jdbc.driver.OracleDriver
acquireIncrement =1
initialPoolSize =5
maxPoolSize = 300\"
了MinPoolSize = 5
maxIdleTime = 600
maxIdleTimeExcessConnections = 300
unreturnedConnectionTimeout = 900
numHelperThreads = 20
name =
user =
password =
factory =org.apache.naming.factory.BeanFactory
type =com.mchange.v2 .c3p0.ComboPooledDataSource
jdbcUrl =jdbc:oracle:oci:/>

与其他DBA交谈时,他说Oracle的一个实例获得了完整的磁盘,并在这一刻创建了寄存器部分提交,但他只是删除了跟踪文件,并没有停止数据库,也没有终止任何会话。

没有足够的信息来说明某些事情,但这听起来像是你看到它没有完成的事务处理。 JDBC规范默默无闻地讨论了未完成事务会发生什么情况。甲骨文是我所知道的唯一供应商,因此决定采取最佳行动方式是在这种情况下开展工作。


Recently got this following error in my application JPA/Hibernate with database Oracle RAC 11g.

This error occurred when our storage was full and DBA needed close connections, kill active sessions, or some like this "Connection closed" (now I can know what happened, he was fired....)

javax.persistence.RollbackException: Error while commiting the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)
at com.cgmp.ValePedagioSite.comprarViagemPorPlaca(ValePedagioSite.java:473)
at sun.reflect.GeneratedMethodAccessor1719.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
        (...)
Caused by: org.hibernate.exception.JDBCConnectionException: could not insert: [com.cgmp.model.entity.PedagioPracaViagem]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2295)
        (...)
Caused by: java.sql.SQLRecoverableException: Connection closed
at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3331)
at oracle.jdbc.driver.T2CConnection.prepareStatement(T2CConnection.java:47)
at oracle.jdbc.driver.PhysicalConnection.prepareStatement(PhysicalConnection.java:3232)
at oracle.jdbc.driver.T2CConnection.prepareStatement(T2CConnection.java:47)
at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:213)
        (...)

Others entities was inserted without problem...

--- EDITED ---

More informations

Configuration c3p0

<Resource auth="Container"
description=""
driverClass="oracle.jdbc.driver.OracleDriver"
acquireIncrement="1"
initialPoolSize="5"
maxPoolSize="300"
minPoolSize="5"
maxIdleTime="600"
maxIdleTimeExcessConnections="300"
unreturnedConnectionTimeout="900"
numHelperThreads="20"
name=""
user=""
password=" "
factory="org.apache.naming.factory.BeanFactory"
type="com.mchange.v2.c3p0.ComboPooledDataSource"
jdbcUrl="jdbc:oracle:oci:" />

Talking with other DBA he said that one instance from Oracle got full disk, and the registers partial commiteds was created in this moment, but he just deleted trace files, didn't stop db and not killed any session.

解决方案

Well there is not enough information to say for certain, but it sounds like what you are seeing it non-completed transaction handling. The JDBC spec is silently on the issue of what should happen in the case of non-completed transactions. Oracle is the only vendor I know of that decided the best course of action was to commit the work in that situation.

这篇关于在Oracle中使用Hibernate / JPA关闭连接时的部分提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆