Forums: Open Discussion (Thread #24667)

【バッチFW】SQL初期データ取得時の単体テストでのバインド方法 (2009-11-24 10:30 by せいら #47135)

お世話になります。

標題の件、初期データ取得時(SQL)に【ジョブコンテキスト】に下記のようにバインドしてSQLデータを取得してきています。
実行時には上手くいきますが、単体テスト時にバインドをして取得しようとしても下記のようなエラーが出てうまくいきません。
どのように記述すれば単体テストで実施できるのでしょうか。

非常に困ってます、どなたかご教授の程よろしくお願いします。

●ジョブコンテキスト
------------------------------------------------------------------------------------------
/**
* 起動時のバインドパラメータを設定する。
*
* @param arg 起動時に指定した第3引数以降の値
*/
@Override
public void setParameter(String[] arg) {
String MARKET_DIVISION = "hoge"

String[] bindParam = {hoge};

this.parameter = bindParam;
}
------------------------------------------------------------------------------------------
●SQL
------------------------------------------------------------------------------------------
select * from hoge where id = #parameter[0]#

------------------------------------------------------------------------------------------
●単体テストの取得記述
------------------------------------------------------------------------------------------
String parameter[]={hoge};
hogeDto[] datas = queryDAO.executeForObjectArray("hoge.selectHoge", parameter, hogeDto.class);
------------------------------------------------------------------------------------------

●エラー内容
------------------------------------------------------------------------------------------
org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];
--- The error occurred in definition/Hoge_sqlMap.xml.
--- The error occurred while preparing the mapped statement for execution.
--- Check the marginCallJudgment.selectHoge.
--- Check the parameter map.
--- Cause: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'parameter' in class '[Ljava.lang.String;'; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in definition/Hoge_sqlMap.xml.
--- The error occurred while preparing the mapped statement for execution.
--- Check the marginCallJudgment.selectHoge.
--- Check the parameter map.
--- Cause: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'parameter' in class '[Ljava.lang.String;'
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in definition/Hoge_sqlMap.xml.
--- The error occurred while preparing the mapped statement for execution.
--- Check the marginCallJudgment.selectHoge.
--- Check the parameter map.
--- Cause: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'parameter' in class '[Ljava.lang.String;'
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:615)
at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)
at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:268)
at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:193)
at org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:219)
at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:266)
at jp.terasoluna.fw.dao.ibatis.QueryDAOiBatisImpl.executeForObjectArray(QueryDAOiBatisImpl.java:267)
at logic.returns.Hoge.HogenReturnTest.testHogen01(HogenReturnTest.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at jp.co.dgic.eclipse.jdt.internal.junit.runner.DJUnitRunner.main(DJUnitRunner.java:49)
Caused by: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'parameter' in class '[Ljava.lang.String;'
at com.ibatis.common.beans.ClassInfo.getGetter(ClassInfo.java:259)
at com.ibatis.common.beans.ComplexBeanProbe.getProperty(ComplexBeanProbe.java:304)
at com.ibatis.common.beans.BaseProbe.getIndexedProperty(BaseProbe.java:56)
at com.ibatis.common.beans.GenericProbe.getObject(GenericProbe.java:56)
at com.ibatis.sqlmap.engine.exchange.ComplexDataExchange.getData(ComplexDataExchange.java:65)
at com.ibatis.sqlmap.engine.mapping.parameter.BasicParameterMap.getParameterObjectValues(BasicParameterMap.java:132)
at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:165)
... 34 more



------------------------------------------------------------------------------------------

Reply to #47135×

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: 【バッチFW】SQL初期データ取得時の単体テストでのバインド方法 (2009-11-24 10:42 by taromaru #47136)

> There is no READABLE property named 'parameter' in
> class '[Ljava.lang.String;'
パラメータとして渡されたオブジェクト(String配列)から、
「parameter」というプロパティを取ろうとしたが、
プロパティ「parameter」が定義されていなかった
というメッセージです。

parameter(String配列)を、ジョブコンテキストにセットして、
queryDAO.executeForObjectArrayの第2引数には
ジョブコンテキストを与えてください。
それで動作すると思います。
Reply to #47135

Reply to #47136×

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: 【バッチFW】SQL初期データ取得時の単体テストでのバインド方法 (2009-11-24 11:00 by せいら #47138)

早速試してみましたが正常に動作することを確認いたしました。

すっごく困っていたんで嬉しいです。

本当にありがとうございました。
またよろしくお願い致します。
Reply to #47135

Reply to #47138×

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