Forums: Open Discussion (Thread #23469)

【バッチ】IBatisDbCollectorImplを使用してQueryDAOにAOP (2009-07-25 16:53 by Anonymous #45137)

お世話になっております。

バッチの機能について質問があります。
jp.terasoluna.fw.batch.ibatissupport.IBatisDbCollectorImplを使用して対象データを取得しようとしていますが、例外が発生してしまいます(最後にスタックトレース抜粋をはっています。)
原因としては、QueryDAOにorg.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreatorを使用してAOPをかけているため、発生していると思っています。

BeanNameAutoProxyCreatorのproxyTargetClass属性をfalseにしているため、org.springframework.orm.ibatis.support.SqlMapClientDaoSupportで宣言されたフィールドにjp.terasoluna.fw.dao.QueryDAOを設定できないための例外だと思っています。
ただproxyTargetClassをtrueにすると、SqlMapClientDaoSupportのfinalメソッドを使用できなくなってしまうため、やはり落ちてしまいます・・・

回避策ご存知の方、いましたらご教授お願いします。

--- 例外スタックトレース
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [$Proxy0] to required type [org.springframework.orm.ibatis.support.SqlMapClientDaoSupport] for property 'queryDAO'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy0] to required type [org.springframework.orm.ibatis.support.SqlMapClientDaoSupport] for property 'queryDAO': no matching editors or conversion strategy found
Caused by: java.lang.IllegalArgumentException: Cannot convert value of type [$Proxy0] to required type [org.springframework.orm.ibatis.support.SqlMapClientDaoSupport] for property 'queryDAO': no matching editors or conversion strategy found

--- 例外スタックトレース ここまで

Reply to #45137×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: 【バッチ】IBatisDbCollectorImplを使用してQueryDAOにAOP (2009-07-27 14:29 by ahn #45153)

回避策として以下の方法は如何でしょうか?

IBatisDbCollectorImplにはAPOをかけない方法

手順①:dataAccessContext-batch.xmlの修正
dataAccessContext-batch.xmlに以下のような設定を追加
<bean id="queryDAONoProxy" class="jp.terasoluna.fw.dao.ibatis.QueryDAOiBatisImpl">
<property name="sqlMapClient" ref="sqlMapClient" />
</bean>

手順②:FrameworkBean.xmlのCollector設定の修正
FrameworkBean.xml内でIBatisDbCollectorImplを使っているBean定義を上記のDAOを
使うよう修正する。
例えば使用中のCollectorが「IBatisDbChunkCollector」の場合は
<bean id="IBatisDbChunkCollector"
class="jp.terasoluna.fw.batch.ibatissupport.IBatisDbCollectorImpl"
abstract="true">
<property name="queryDAO" ref="queryDAONoProxy" />
<property name="collectedDataHandlerFactory">
<bean class="jp.terasoluna.fw.batch.standard.ChunkerFactory">
<property name="chunkSize" ref="chunkSize" />
</bean>
</property>
</bean>

手順③:IBatisDbChunkCollectorには必要に応じてAOP設定を追加する。

上記の設定でIBatisDbCollectorImplはAOPの対象外になり例外は発生しないと思います。
他に「sqlMapClient」にAOPを設定するなどの、回避策はあるかと思います。
Reply to #45137

Reply to #45153×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login