出错信息类似:
[2008-12-08 12:46:33.10 GMT+08:00] [WARN ] [org.hibernate.util.JDBCExceptionReporter] SQL Warning: 0, SQLState:
[2008-12-08 12:46:33.10 GMT+08:00] [WARN ] [org.hibernate.util.JDBCExceptionReporter] [BEA][Sybase JDBC Driver]Database changed to DBNAME
[2008-12-08 12:46:33.10 GMT+08:00] [WARN ] [org.hibernate.util.JDBCExceptionReporter] SQL Warning: 0, SQLState:
[2008-12-08 12:46:33.10 GMT+08:00] [WARN ] [org.hibernate.util.JDBCExceptionReporter] [BEA][Sybase JDBC Driver]Language changed to us_english
这些是通过查看weblogic日志发现的一些情况,且出现频率比较高,但应用又正常,查遍网络,最终在一个帖子中找到,并在springframework网站一个帖子找到了原委:
Well, the read-only flag is a kind of stepchild in the JDBC spec... Many drivers (and DBMS) don't really support a true read-only transaction. Some do optimize transaction processing, though, so setting the readOnly flag is nevertheless usually worth it.
In your case, the driver simply isn't able to switch the connection to true read-only mode and logs a corresponding warning. This can safely be ignored; your transaction won't get read-only optimizations, but that doesn't hurt.
You could remove the "readOnly" marker from your transaction attribute to avoid the warning. However, "readOnly" also triggers other optimizations, for example it suppresses Hibernate flush attempts for read-only operations, so I recommend to keep those markers and simply ignore the warnings.
--------------------------------------------------
springframework.org 上原帖:
http://forum.springframework.org/showthread.php?t=12637
原帖内容:
All,
I have an application running on WebSphere Server v5.1.1 that uses Spring and Hibernate to access a remote DB2 v8.2 database via IBM DB2 JDBC Type 4 driver. I have a method whose transaction attribute is set to readonly through Spring config file
******* BEGIN SPRING CONFIG FILE **********
...
<bean id="organizationService" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="target"><ref local="organizationServiceTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="executeOrganizationSearch">PROPAGATION_REQUIR ED,readOnly</prop>
</props>
</property>
</bean>
...
******* END SPRING CONFIG FILE **********
It retrieves the information I need but it keeps giving the following warning:
"JDBCExceptionReporter - SQL Warning
com.ibm.db2.jcc.b.SqlWarning: Connection readOnly mode is not enforcable after the connection has been established. To enforce a read only connection, set the readOnly data source or connection property. "
I do not have this problem when I use IBM DB2 JDBC TYPE 2, but applications in production environment must use TYPE 4 driver.
******* BEGIN WARNING *******
...
2005-01-26 18:18:21,717 DEBUG TransactionInterceptor - Invoking commit for trans
action on method 'executeOrganizationSearch' in class [us.il.state.idph.fdd.serv
ice.demographics.OrganizationService]
2005-01-26 18:18:21,717 DEBUG HibernateTransactionManager - Triggering beforeCom
mit synchronization
2005-01-26 18:18:21,718 DEBUG HibernateTransactionManager - Triggering beforeCom
pletion synchronization
2005-01-26 18:18:21,718 DEBUG HibernateTransactionManager - Initiating transacti
on commit
2005-01-26 18:18:21,718 DEBUG HibernateTransactionManager - Committing Hibernate
transaction on session [net.sf.hibernate.impl.SessionImpl@1e05ce0]
2005-01-26 18:18:21,718 DEBUG JDBCTransaction - commit
2005-01-26 18:18:21,719 DEBUG SessionImpl - transaction completion
2005-01-26 18:18:21,719 DEBUG JDBCTransaction - re-enabling autocommit
2005-01-26 18:18:21,719 DEBUG HibernateTransactionManager - Triggering afterComp
letion synchronization
2005-01-26 18:18:21,720 DEBUG TransactionSynchronizationManager - Clearing trans
action synchronization
2005-01-26 18:18:21,720 DEBUG TransactionSynchronizationManager - Removed value
[org.springframework.orm.hibernate.SessionHolder@6d d766] for key [net.sf.hiberna
te.impl.SessionFactoryImpl@11bd50e] from thread [Servlet.Engine.Transports : 0]
2005-01-26 18:18:21,720 DEBUG TransactionSynchronizationManager - Removed value
[org.springframework.jdbc.datasource.ConnectionHold er@1a9f278] for key [com.ibm.
ws.rsadapter.jdbc.WSJdbcDataSource@1ac9cff] from thread [Servlet.Engine.Transpor
ts : 0]
2005-01-26 18:18:21,720 DEBUG DataSourceUtils - Resetting read-only flag of conn
ection [com.ibm.ws.rsadapter.jdbc.WSJccConnection@1620aa9]
2005-01-26 18:18:21,721 DEBUG HibernateTransactionManager - Closing Hibernate se
ssion [net.sf.hibernate.impl.SessionImpl@1e05ce0] after transaction
2005-01-26 18:18:21,721 DEBUG SessionFactoryUtils - Closing Hibernate session
2005-01-26 18:18:21,721 DEBUG SessionImpl - closing session
2005-01-26 18:18:21,721 DEBUG SessionImpl - disconnecting session
2005-01-26 18:18:21,722 DEBUG JDBCExceptionReporter - SQL Warning
com.ibm.db2.jcc.b.SqlWarning: Connection readOnly mode is not enforcable after t
he connection has been established. To enforce a read only connection, set the r
eadOnly data source or connection property.
at com.ibm.db2.jcc.b.o.setReadOnly(o.java:1507)
at com.ibm.db2.jcc.b.wb.setReadOnly(wb.java:202)
at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImp l.setReadOnly(WSRdb
ManagedConnectionImpl.java:3280)
at com.ibm.ws.rsadapter.spi.InternalGenericDataStoreH elper.setReadOnly(I
nternalGenericDataStoreHelper.java:266)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.setRead Only(WSJdbcConnecti
on.java:2115)
at org.springframework.jdbc.datasource.DataSourceUtil s.prepareConnection
ForTransaction(DataSourceUtils.java:194)
at org.springframework.orm.hibernate.HibernateTransac tionManager.doBegin
(HibernateTransactionManager.java:378)
at org.springframework.transaction.support.AbstractPl atformTransactionMa
nager.getTransaction(AbstractPlatformTransactionMa nager.java:269)
at org.springframework.transaction.interceptor.Transa ctionAspectSupport.
createTransactionIfNecessary(TransactionAspectSupp ort.java:200)
at org.springframework.transaction.interceptor.Transa ctionInterceptor.in
voke(TransactionInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(
ReflectiveMethodInvocation.java:138)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynami
cAopProxy.java:152)
at $Proxy0.executeOrganizationSearch(Unknown Source)
at us.il.state.idph.fdd.web.party.SearchOrganizationA ction.getSearchOrga
nization(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.struts.actions.DispatchAction.dispatchM ethod(DispatchActio
n.java:278)
at org.apache.struts.actions.DispatchAction.execute(D ispatchAction.java:
218)
...
******* END WARNING *******
I hope you guys can help me. Thanks !
Regards,
Guillermo
<!---->
<!---->
<!---->
<!----> Jan 27th, 2005, 06:20 AM <!---->
|
<!---->
Senior Member
Spring Team
|
|
Join Date: Aug 2004
Location: Linz, Austria
Posts: 391
|
<!----> |
<!----><!---->
<!----><!---->
Well, the read-only flag is a kind of stepchild in the JDBC spec... Many drivers (and DBMS) don't really support a true read-only transaction. Some do optimize transaction processing, though, so setting the readOnly flag is nevertheless usually worth it.
In your case, the driver simply isn't able to switch the connection to true read-only mode and logs a corresponding warning. This can safely be ignored; your transaction won't get read-only optimizations, but that doesn't hurt.
You could remove the "readOnly" marker from your transaction attribute to avoid the warning. However, "readOnly" also triggers other optimizations, for example it suppresses Hibernate flush attempts for read-only operations, so I recommend to keep those markers and simply ignore the warnings.
Juergen
<!---->
<!----> <!---->
<!----> |
<!---->
<!---->
<!---->
<!----> Apr 15th, 2005, 06:48 PM <!---->
|
<!---->
sjivan
<script type="text/javascript"></script>
Senior Member
|
|
Join Date: Sep 2004
Location: Boston, US
Posts: 130
|
<!----> |
<!----><!---->
<!----><!---->
Quote:
In your case, the driver simply isn't able to switch the connection to true read-only mode and logs a corresponding warning. This can safely be ignored; your transaction won't get read-only optimizations, but that doesn't hurt.
You could remove the "readOnly" marker from your transaction attribute to avoid the warning. However, "readOnly" also triggers other optimizations, for example it suppresses Hibernate flush attempts for read-only operations, so I recommend to keep those markers and simply ignore the warnings. |
I discovered that setting the "readOnly" marker is more than a nice-to-have. I had a problem http://forum.springframework.org/viewtopic.php?t=4849 when using Spring MVC where despite having validation errors in my onBindAndValidate() method, the bad user entered values bound to my domain objects would get persisted by Hibernate. Turned out that this was because I had the transaction attribute for all service methods without the readOnly marker.
Code:
<prop key="*">PROPAGATION_REQUIRED</prop>
After changing the transaction attributes to
Code:
<prop key="save*">PROPAGATION_REQUIRED</prop>
<prop key="delete*">PROPAGATION_REQUIRED</prop>
<prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
the invalid bean properties did not get persisted if validation errors were present. Sanjiv
|
分享到:
相关推荐
如何防止 Hibernate报警告 WARM:.... 将这个资源放到你的 src 目录下就可以了。
Configuration 是 Hibernate 的核心配置对象,它提供了一些方法来配置 Hibernate 的核心配置信息。例如,Configuration 对象可以用于指定 Hibernate 的数据库连接信息、 mappings 等。 2. SessionFactory ...
Struts Hibernate Spring Ajax Struts Hibernate Spring Ajax
在本项目中,"用Struts2加Hibernate对学员信息进行增删改查操作",主要涉及了以下几个核心知识点: 1. **Struts2框架**:Struts2是一个MVC(Model-View-Controller)架构的Java框架,它提供了处理HTTP请求和响应的...
在 Hibernate 的配置文件中,我们可以配置不同的数据库连接,包括驱动程序、URL 等信息。 配置 Hibernate 连接数据库 在 Hibernate 的配置文件中,我们可以使用 properties 文件或 XML 文件来配置数据库连接。下面...
以下是对Hibernate的一些关键知识点的详细说明: 1. **异常处理**: 在描述中提到的`org.hibernate.PropertyValueException: not-null property references a null or transient value`是Hibernate抛出的一个常见...
本项目"struts2+hibernate的简单学生信息管理"是一个适合初学者实践的教程,它展示了如何将这两种技术结合使用来实现一个基本的信息管理系统。 Struts2作为MVC(模型-视图-控制器)框架,主要负责处理HTTP请求,...
Hibernate配置文件hibernate.cfg.xml中配置信息详解!
SSH(Struts2 + Spring + Hibernate)教务信息管理系统是一个基于Java技术的Web应用程序,它利用了三个核心的开源框架来构建高效、可维护且功能丰富的教育管理平台。SSH是Struts2、Spring和Hibernate的缩写,这些...
在Hibernate中,你需要一个具体的日志实现来记录框架内部的调试信息和警告。 6. **javassist.jar**:这个库是Hibernate的代码生成器,用于动态创建和修改类,特别是在运行时根据映射信息生成代理类。 7. **jta.jar...
另外,还有一些以`dialect`结尾的jar文件,如`hibernate-5.0.12.Finaldialect.jar`,这些通常是针对特定数据库的方言(Dialect)实现,用于告诉Hibernate如何正确地与特定类型的数据库进行交互。KingbaseV8的方言...
* 配置 Hibernate:在 hibernate.cfg.xml 文件中配置 Hibernate 的一些常用信息,例如 JDBC 连接数据库的信息。 * 使用 Hibernate:使用 Hibernate 来操作数据库,例如执行查询、插入、更新、删除等操作。 四、 ...
4. Hibernate配置:在使用Hibernate时,通常需要一个hibernate.cfg.xml配置文件,其中包含了数据库连接信息、方言设置、缓存配置等,它是Hibernate启动的入口。 5. Hibernate实体类:开发者定义的Java类,通过@...
8. **持久化类和映射文件**:持久化类是与数据库表对应的Java类,通常包含一些特定的注解或XML映射文件(hibernate-mapping)来定义它们与数据库的映射关系。 9. **懒加载和立即加载**:懒加载是Hibernate的一种...
hibernate.cfg.xml 文件是 Hibernate 的基本配置文件,它包含了 Hibernate 与数据库的基本连接信息。在 Hibernate 工作的初始阶段,这些信息被加载到 Configuration 和 SessionFactory 实例中。该文件的基本结构如下...
hibernate的一些库 dom4j.jar ejb3-persistence.jar hibernate-annotations.jar hibernate-core.jar slf4j-api.jar hibernate-commons-annotations.jar等
hibernate.cfg.xml 文件中定义了 Hibernate 的连接信息、数据库信息、映射信息等。 映射定义(Mapping declaration) 映射定义是 Hibernate 中的一个重要概念,用于定义对象到关系数据库的映射关系。映射定义可以...
hibernate 5.2.15 hibernate 5.2.15 hibernate 5.2.15 hibernate 5.2.15 hibernate 5.2.15hibernate 5.2.15
4. **示例**:包含了一些演示如何使用Hibernate的代码示例,有助于理解其用法。 5. **配置文件**:可能有默认的配置模板,展示如何配置Hibernate以连接数据库。 6. **许可证文件**:关于软件的授权信息,通常遵循...