Spring ReadOnly使用WebSphere和Oracle传播Propapation.SUPPORTS [英] Spring ReadOnly Transaction with Propagation.SUPPORTS with WebSphere and Oracle

查看:379
本文介绍了Spring ReadOnly使用WebSphere和Oracle传播Propapation.SUPPORTS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我从Hibernate 3.6切换到Hibernate 4.1.x,我在Transaction / Session管理上遇到了一些问题。我使用Spring 3.1.2,Hibernate 4.1.4 ,WebSphere 8.5和Oracle 11.



在我的WebApp中,我标记了一些方法:

  @Transactional(propagation = Propagation.SUPPORTS,readOnly = true)

我的webapp使用了OpenSessionInViewFilter和getSessionFactory()。getCurrentSession()。

但是我的一些代码被JMS或Quartz作业调用(没有OpenSessionInViewFilter),导致

  org.hibernate.HibernateException:没有找到当前线程的会话
在org.springframework.orm.hibernate4.SpringSessionContext .currentSession(SpringSessionContext.java:97)

经过在互联网上的一些研究,我把我的交易改为:

  @Transactional(propagation = Propag ation.REQUIRED,readOnly = true)

现在有一个开放的会话,对Tomcat一切正常,但在WebSphere上,我得到以下错误:

pre code $ [SqlExceptionHelper]:SQL错误:0,SQLState:null
[SqlExceptionHelper ]:DSRA9010E:'setReadOnly'wird in der WebSphere-Implementierung java.sql.Connection nichtunterstützt。

有些帖子说,Oracle不支持只读。但通过Propagation.SUPPORTS或Tomcat工作。
现在我不知道该怎么做。用Propagation标记JMS调用的所有方法.REQUIRED和readOnly = false?



有更好的想法吗?或者在使用WebSphere时这是Spring中的一个错误?

解决方案

翻译英文错误时说:

  DSRA9010E:WebSphere实现中不支持'setReadOnly'java.sql.Connection 

这不是一个错误,只是它们没有实现只读。如果使用Connection Pooling,这也是可以理解的,因为readonly通常是一个连接创建作用域属性。



此外,readonly只是jdbc提供程序的一个建议:jdbc提供者可以忽略它,据我所知,许多提供者并没有为它做任何事情。



只是不指定只读。






要回答下面的Sam注释:
Hibernate与该错误无关,它是实现 java.sql的Websphere组件如 DSRA9010E 错误。 wss?uid = swg21194913rel =nofollow> here 由IBM自己具体说明,错误代码DSRA9010E和说明'setReadOnly'不支持IBM WebSphere Application Server java.sql.Connection实现




解决问题

2003年6月,对Application Server代码$ b进行了更改$ b缺陷168102.在2003年6月之前,setReadOnly(true)方法在Application Server中设置了一个
内部标志,但未将此
信息传递给Oracle数据库。在2003年6月以后的版本中,
Application Server发出上述错误。


整篇文章是为了清楚起见,他们稍后在错误168102的解决方案中添加了此错误,以解决问题:让客户知道设置该标志对基础数据库连接没有影响,因为Oracle不支持它。

在文章结尾处,他们建议升级到最新版本(发布错误的版本)。

I have some problems with Transaction/Session management, since I switched from Hibernate 3.6 to Hibernate 4.1.x

I use Spring 3.1.2, Hibernate 4.1.4, WebSphere 8.5 and Oracle 11.

In my WebApp I have marked some methods with:

@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)

Thats working fine for my webapp which uses OpenSessionInViewFilter and getSessionFactory().getCurrentSession().

But some of my code is called by JMS or Quartz job (without the OpenSessionInViewFilter) resulting in

org.hibernate.HibernateException: No Session found for current thread
    at org.springframework.orm.hibernate4.SpringSessionContext.currentSession(SpringSessionContext.java:97)

After some researches in the Internet I changed my Transaction to :

@Transactional(propagation = Propagation.REQUIRED, readOnly = true)

Now there is an open Session and everything is OK for Tomcat but on WebSphere I get the following error:

[SqlExceptionHelper] : SQL Error: 0, SQLState: null
[SqlExceptionHelper] : DSRA9010E: 'setReadOnly' wird in der WebSphere-Implementierung  java.sql.Connection nicht unterstützt.

Some posts say, Oracle isn´t supporting readonly. But with Propagation.SUPPORTS or with Tomcat it´s working. Now I don´t know what to do. Marking all methods called by JMS with Propagation.REQUIRED and readOnly = false?

Any better ideas? Or is this a bug in Spring when using WebSphere?

解决方案

Translating the error in english it says:

DSRA9010E: 'setReadOnly' is not supported in the WebSphere implementation java.sql.Connection

Which is not a bug, it's simply that they are not implementing read-only. And that is also understandable if using a Connection Pooling because readonly is usually a connection creation scoped attribute.

Moreover readonly is only a "suggestion" for the jdbc provider: the jdbc provider can ignore it and as far as I know many providers don't really do anything for it.

Simply don't specify readonly.


To answer Sam comment below: Hibernate has nothing to do with that error, it is the Websphere Component implementing java.sql.Connection that emits DSRA9010E error when using Websphere with Oracle, after June 2003, as explained here by IBM itself about specifically that error code DSRA9010E and description "'setReadOnly' is not supported on the IBM WebSphere Application Server java.sql.Connection implementation":

Resolving the problem

In June 2003, there was a change made to the Application Server code defect 168102. Prior to June 2003, the setReadOnly(true) method set an internal flag in Application Server, but did not convey this information to the Oracle database. In versions after June 2003, Application Server issues the error as described above.

My understanding of the entire article is that they added that error later, to resolve the problem, as a solution to defect 168102, for clarity purpose: to let the client know that setting that flag has no effect on the underlying database connection because Oracle is not supporting it.

At the end of the article they suggest to upgrade to the latest version (the one that emits the error).

这篇关于Spring ReadOnly使用WebSphere和Oracle传播Propapation.SUPPORTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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