Fixed Ibatisjob for updated package names.
This commit is contained in:
@@ -31,16 +31,17 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
/**
|
||||
* {@link InputSource} for reading database records built on top of Hibernate.
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
public class HibernateInputSource implements InputSource, Restartable, InitializingBean, DisposableBean,
|
||||
public class HibernateCursorInputSource implements InputSource, Restartable, InitializingBean, DisposableBean,
|
||||
ResourceLifecycle {
|
||||
|
||||
private static final String RESTART_DATA_ROW_NUMBER_KEY = "HibernateInputSource.rowNumber";
|
||||
private static final String RESTART_DATA_ROW_NUMBER_KEY = ClassUtils.getShortName(HibernateCursorInputSource.class)+".rowNumber";
|
||||
|
||||
private SessionFactory sessionFactory;
|
||||
private StatelessSession session;
|
||||
@@ -18,6 +18,8 @@ package org.springframework.batch.io.driving;
|
||||
import org.springframework.batch.io.driving.support.IbatisKeyGenerator;
|
||||
import org.springframework.orm.ibatis.SqlMapClientTemplate;
|
||||
|
||||
import com.ibatis.sqlmap.client.SqlMapClient;
|
||||
|
||||
/**
|
||||
* Extension of {@link DrivingQueryInputSource} that maps keys to
|
||||
* objects. An iBatis query id must be set to map and return each 'detail record'.
|
||||
@@ -25,7 +27,7 @@ import org.springframework.orm.ibatis.SqlMapClientTemplate;
|
||||
* @author Lucas Ward
|
||||
* @see IbatisKeyGenerator
|
||||
*/
|
||||
public class IbatisInputSource extends DrivingQueryInputSource {
|
||||
public class IbatisDrivingQueryInputSource extends DrivingQueryInputSource {
|
||||
|
||||
private String detailsQueryId;
|
||||
|
||||
@@ -54,8 +56,8 @@ public class IbatisInputSource extends DrivingQueryInputSource {
|
||||
*
|
||||
* @param sqlMapClientTemplate
|
||||
*/
|
||||
public void setSqlMapClientTemplate(
|
||||
SqlMapClientTemplate sqlMapClientTemplate) {
|
||||
this.sqlMapClientTemplate = sqlMapClientTemplate;
|
||||
public void setSqlMapClient(
|
||||
SqlMapClient sqlMapClient) {
|
||||
this.sqlMapClientTemplate = new SqlMapClientTemplate(sqlMapClient);
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,14 @@ package org.springframework.batch.io.cursor;
|
||||
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.batch.io.InputSource;
|
||||
import org.springframework.batch.io.cursor.HibernateInputSource;
|
||||
import org.springframework.batch.io.cursor.HibernateCursorInputSource;
|
||||
import org.springframework.batch.io.support.AbstractDataSourceInputSourceIntegrationTests;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.orm.hibernate3.LocalSessionFactoryBean;
|
||||
|
||||
/**
|
||||
* Tests for {@link HibernateInputSource}
|
||||
* Tests for {@link HibernateCursorInputSource}
|
||||
*
|
||||
* @author Robert Kasanicky
|
||||
*/
|
||||
@@ -25,7 +25,7 @@ public class HibernateInputSourceIntegrationTests extends AbstractDataSourceInpu
|
||||
|
||||
String hsqlQuery = "from Foo";
|
||||
|
||||
HibernateInputSource inputSource = new HibernateInputSource();
|
||||
HibernateCursorInputSource inputSource = new HibernateCursorInputSource();
|
||||
inputSource.setQueryString(hsqlQuery);
|
||||
inputSource.setSessionFactory(sessionFactory);
|
||||
inputSource.afterPropertiesSet();
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package org.springframework.batch.io.driving;
|
||||
|
||||
import org.springframework.batch.io.InputSource;
|
||||
import org.springframework.batch.io.driving.IbatisInputSource;
|
||||
import org.springframework.batch.io.driving.support.IbatisKeyGenerator;
|
||||
import org.springframework.batch.io.support.AbstractDataSourceInputSourceIntegrationTests;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.orm.ibatis.SqlMapClientFactoryBean;
|
||||
import org.springframework.orm.ibatis.SqlMapClientTemplate;
|
||||
|
||||
import com.ibatis.sqlmap.client.SqlMapClient;
|
||||
|
||||
@@ -24,15 +22,14 @@ public class IbatisInputSourceIntegrationTests extends AbstractDataSourceInputSo
|
||||
factory.setDataSource(super.getJdbcTemplate().getDataSource());
|
||||
factory.afterPropertiesSet();
|
||||
SqlMapClient sqlMapClient = (SqlMapClient) factory.getObject();
|
||||
SqlMapClientTemplate sqlMapClientTemplate = new SqlMapClientTemplate(sqlMapClient);
|
||||
|
||||
IbatisInputSource inputSource = new IbatisInputSource();
|
||||
IbatisDrivingQueryInputSource inputSource = new IbatisDrivingQueryInputSource();
|
||||
IbatisKeyGenerator keyGenerator = new IbatisKeyGenerator();
|
||||
keyGenerator.setDrivingQueryId("getAllFooIds");
|
||||
inputSource.setDetailsQueryId("getFooById");
|
||||
keyGenerator.setRestartQueryId("getAllFooIdsRestart");
|
||||
keyGenerator.setSqlMapClient(sqlMapClient);
|
||||
inputSource.setSqlMapClientTemplate(sqlMapClientTemplate);
|
||||
inputSource.setSqlMapClient(sqlMapClient);
|
||||
inputSource.setKeyGenerator(keyGenerator);
|
||||
|
||||
return inputSource;
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateInputSource" class="org.springframework.batch.io.cursor.HibernateInputSource"
|
||||
<bean id="hibernateInputSource" class="org.springframework.batch.io.cursor.HibernateCursorInputSource"
|
||||
scope="step" >
|
||||
<aop:scoped-proxy />
|
||||
<property name="queryString" value="from CustomerCredit" />
|
||||
|
||||
@@ -45,13 +45,18 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="ibatisInputSource" class="org.springframework.batch.io.driving.IbatisInputSource"
|
||||
<bean id="ibatisInputSource" class="org.springframework.batch.io.driving.IbatisDrivingQueryInputSource"
|
||||
scope="step" >
|
||||
<aop:scoped-proxy />
|
||||
<property name="drivingQueryId" value="getAllCustomerCreditIds" />
|
||||
<property name="detailsQueryId" value="getCustomerCreditById" />
|
||||
<property name="sqlMapClient" ref="sqlMapClient" />
|
||||
<property name="sqlMapClient" ref="sqlMapClient" />
|
||||
<property name="keyGenerator" ref="ibatisKeyGenerator" />
|
||||
</bean>
|
||||
|
||||
<bean id="ibatisKeyGenerator" class="org.springframework.batch.io.driving.support.IbatisKeyGenerator">
|
||||
<property name="drivingQueryId" value="getAllCustomerCreditIds" />
|
||||
<property name="sqlMapClient" ref="sqlMapClient" />
|
||||
</bean>
|
||||
|
||||
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
|
||||
<property name="configLocation" value="ibatis-config.xml" />
|
||||
|
||||
Reference in New Issue
Block a user