diff --git a/build.gradle b/build.gradle index bd0a382ce..c6607856d 100644 --- a/build.gradle +++ b/build.gradle @@ -75,7 +75,6 @@ allprojects { hibernateVersion = '5.2.2.Final' hibernateValidatorVersion = '5.3.0.CR1' hsqldbVersion = '2.3.3' - ibatisVersion = '2.3.4.726' jackson2Version = "2.8.6" //? javaMailVersion = '1.5.6' javaxBatchApiVersion = '1.0' @@ -341,7 +340,6 @@ project('spring-batch-infrastructure') { } optional "org.hibernate:hibernate-validator:$hibernateValidatorVersion" optional "javax.transaction:javax.transaction-api:$javaxTransactionVersion" - optional "org.apache.ibatis:ibatis-sqlmap:$ibatisVersion" optional "javax.mail:javax.mail-api:$javaMailVersion" optional "javax.batch:javax.batch-api:$javaxBatchApiVersion" compile("org.springframework:spring-oxm:$springVersion") { dep -> @@ -461,7 +459,6 @@ project('spring-batch-infrastructure-tests') { testCompile "org.mockito:mockito-core:$mockitoVersion" optional "org.slf4j:slf4j-log4j12:$slf4jVersion" - optional "org.apache.ibatis:ibatis-sqlmap:$ibatisVersion" compile("org.hibernate:hibernate-core:$hibernateVersion") { dep -> optional dep exclude group: 'org.jboss.spec.javax.transaction', module: 'jboss-transaction-api_1.1_spec' @@ -573,7 +570,6 @@ project('spring-batch-samples') { exclude group: 'org.jboss.spec.javax.transaction', module: 'jboss-transaction-api_1.1_spec' } compile "javax.transaction:javax.transaction-api:$javaxTransactionVersion" - compile "org.apache.ibatis:ibatis-sqlmap:$ibatisVersion" compile "org.springframework:spring-aop:$springVersion" compile("org.springframework:spring-oxm:$springVersion") { exclude group: 'commons-lang', module: 'commons-lang' diff --git a/spring-batch-core-tests/.springBeans b/spring-batch-core-tests/.springBeans index 5dbfbb4be..b4afd61c9 100644 --- a/spring-batch-core-tests/.springBeans +++ b/spring-batch-core-tests/.springBeans @@ -268,15 +268,6 @@ - - - true - false - - - - - true diff --git a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java b/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java deleted file mode 100644 index 4fe02b68f..000000000 --- a/spring-batch-infrastructure-tests/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright 2010-2014 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.item.database; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.CompletionService; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorCompletionService; -import java.util.concurrent.Executors; - -import javax.sql.DataSource; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.batch.item.sample.Foo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ClassPathResource; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.jdbc.JdbcTestUtils; -import org.springframework.util.Assert; - -import com.ibatis.sqlmap.client.SqlMapClient; -import com.ibatis.sqlmap.client.SqlMapClientBuilder; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = "JdbcPagingItemReaderCommonTests-context.xml") -@SuppressWarnings("deprecation") -public class IbatisPagingItemReaderAsyncTests { - - /** - * The number of items to read - */ - private static final int ITEM_COUNT = 1000; - - /** - * The number of threads to create - */ - private static final int THREAD_COUNT = 10; - - private static Log logger = LogFactory.getLog(IbatisPagingItemReaderAsyncTests.class); - - @Autowired - private DataSource dataSource; - - private int maxId; - - @Before - public void init() { - Assert.notNull(dataSource); - JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); - maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class); - for (int i = ITEM_COUNT; i > maxId; i--) { - jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i); - } - assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); - } - - @After - public void destroy() { - JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); - jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId); - } - - @Test - public void testAsyncReader() throws Throwable { - List throwables = new ArrayList(); - int max = 10; - for (int i = 0; i < max; i++) { - try { - logger.info("Testing asynch reader, iteration="+i); - doTest(); - } - catch (Throwable e) { - throwables.add(e); - } - } - if (!throwables.isEmpty()) { - throw new IllegalStateException(String.format("Failed %d out of %d", throwables.size(), max), throwables - .get(0)); - } - } - - /** - * @throws Exception - * @throws InterruptedException - * @throws ExecutionException - */ - private void doTest() throws Exception, InterruptedException, ExecutionException { - final IbatisPagingItemReader reader = getItemReader(); - reader.setDataSource(dataSource); - CompletionService> completionService = new ExecutorCompletionService>(Executors - .newFixedThreadPool(THREAD_COUNT)); - for (int i = 0; i < THREAD_COUNT; i++) { - completionService.submit(new Callable>() { - @Override - public List call() throws Exception { - List list = new ArrayList(); - Foo next = null; - do { - next = reader.read(); - Thread.sleep(10L); // try to make it fairer - logger.debug("Reading item: " + next); - if (next != null) { - list.add(next); - } - } while (next != null); - return list; - } - }); - } - int count = 0; - Set results = new HashSet(); - for (int i = 0; i < THREAD_COUNT; i++) { - List items = completionService.take().get(); - count += items.size(); - logger.debug("Finished items count: " + items.size()); - logger.debug("Finished items: " + items); - assertNotNull(items); - results.addAll(items); - } - assertEquals(ITEM_COUNT, count); - assertEquals(ITEM_COUNT, results.size()); - reader.close(); - } - - private IbatisPagingItemReader getItemReader() throws Exception { - SqlMapClient sqlMapClient = createSqlMapClient(); - - IbatisPagingItemReader reader = new IbatisPagingItemReader(); - if ("postgres".equals(System.getProperty("ENVIRONMENT"))) { - reader.setQueryId("getPagedFoosPostgres"); - } else if ("oracle".equals(System.getProperty("ENVIRONMENT"))) { - reader.setQueryId("getPagedFoosOracle"); - } else { - reader.setQueryId("getPagedFoos"); - } - reader.setPageSize(2); - reader.setSqlMapClient(sqlMapClient); - reader.setSaveState(true); - - reader.afterPropertiesSet(); - - return reader; - } - - private SqlMapClient createSqlMapClient() throws Exception { - return SqlMapClientBuilder.buildSqlMapClient(new ClassPathResource("ibatis-config.xml", getClass()).getInputStream()); - } - -} diff --git a/spring-batch-infrastructure-tests/src/test/resources/org/springframework/batch/item/database/ibatis-config.xml b/spring-batch-infrastructure-tests/src/test/resources/org/springframework/batch/item/database/ibatis-config.xml deleted file mode 100644 index f23807357..000000000 --- a/spring-batch-infrastructure-tests/src/test/resources/org/springframework/batch/item/database/ibatis-config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/spring-batch-infrastructure-tests/src/test/resources/org/springframework/batch/item/database/ibatis-foo.xml b/spring-batch-infrastructure-tests/src/test/resources/org/springframework/batch/item/database/ibatis-foo.xml deleted file mode 100644 index 307e03e5f..000000000 --- a/spring-batch-infrastructure-tests/src/test/resources/org/springframework/batch/item/database/ibatis-foo.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - insert INTO T_WRITE_FOOS (ID, NAME, VALUE) VALUES (#id#, #name#, #value#) - - - - update T_WRITE_FOOS set NAME = #name#, VALUE = #value# where ID = #id# - - - - delete from T_WRITE_FOOS where ID = #id# - - - \ No newline at end of file diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java deleted file mode 100644 index 0d8a22f39..000000000 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisBatchItemWriter.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright 2006-2014 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.item.database; - -import com.ibatis.sqlmap.client.SqlMapClient; -import com.ibatis.sqlmap.client.SqlMapSession; -import com.ibatis.sqlmap.engine.execution.BatchException; -import com.ibatis.sqlmap.engine.execution.BatchResult; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.batch.item.ItemWriter; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.dao.EmptyResultDataAccessException; -import org.springframework.dao.InvalidDataAccessResourceUsageException; -import org.springframework.jdbc.CannotGetJdbcConnectionException; -import org.springframework.jdbc.datasource.DataSourceUtils; -import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; -import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator; -import org.springframework.jdbc.support.SQLExceptionTranslator; -import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator; -import org.springframework.util.Assert; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.List; - -/** - * {@link ItemWriter} that uses the batching features from - * SqlMapClient to execute a batch of statements for all items - * provided.
- * - * The user must provide an iBATIS statement id that points to the SQL statement defined - * in the iBATIS SqlMap configuration.
- * - * It is expected that {@link #write(List)} is called inside a transaction.
- * - * The writer is thread-safe after its properties are set (normal singleton - * behavior), so it can be used to write in multiple concurrent transactions.
- * - * Note: This reader was refactored as part of Spring Batch 3.0 to use the iBatis - * APIs directly instead of using Spring's SqlMapClientTemplate as part of the upgrade to - * support Spring 4. - * - * @author Thomas Risberg - * @author Michael Minella - * @since 2.0 - * @deprecated as of Spring Batch 3.0, in favor of the native Spring Batch support - * in the MyBatis follow-up project (http://mybatis.github.io/spring/) - */ -@Deprecated -public class IbatisBatchItemWriter implements ItemWriter, InitializingBean { - - protected static final Log logger = LogFactory.getLog(IbatisBatchItemWriter.class); - - private String statementId; - - private boolean assertUpdates = true; - - private SqlMapClient sqlMapClient; - - private DataSource dataSource; - - public void setDataSource(DataSource dataSource) { - this.dataSource = dataSource; - } - - /** - * Public setter for the flag that determines whether an assertion is made - * that all items cause at least one row to be updated. - * - * @param assertUpdates the flag to set. Defaults to true; - */ - public void setAssertUpdates(boolean assertUpdates) { - this.assertUpdates = assertUpdates; - } - - /** - * Public setter for {@link SqlMapClient} for injection purposes. - * - * @param sqlMapClient the SqlMapClient - */ - public void setSqlMapClient(SqlMapClient sqlMapClient) { - this.sqlMapClient = sqlMapClient; - } - - /** - * Public setter for the statement id identifying the statement in the SqlMap - * configuration file. - * - * @param statementId the id for the statement - */ - public void setStatementId(String statementId) { - this.statementId = statementId; - } - - /** - * Check mandatory properties - there must be an SqlMapClient and a statementId. - */ - @Override - public void afterPropertiesSet() { - Assert.notNull(sqlMapClient, "A SqlMapClient is required."); - Assert.notNull(statementId, "A statementId is required."); - } - - /* (non-Javadoc) - * @see org.springframework.batch.item.ItemWriter#write(java.util.List) - */ - @Override - public void write(final List items) { - - if (!items.isEmpty()) { - - if (logger.isDebugEnabled()) { - logger.debug("Executing batch with " + items.size() + " items."); - } - - List results = execute(items); - - if (assertUpdates) { - if (results.size() != 1) { - throw new InvalidDataAccessResourceUsageException("Batch execution returned invalid results. " + - "Expected 1 but number of BatchResult objects returned was " + results.size()); - } - - int[] updateCounts = results.get(0).getUpdateCounts(); - - for (int i = 0; i < updateCounts.length; i++) { - int value = updateCounts[i]; - if (value == 0) { - throw new EmptyResultDataAccessException("Item " + i + " of " + updateCounts.length - + " did not update any rows: [" + items.get(i) + "]", 1); - } - } - } - } - } - - @SuppressWarnings("unchecked") - private List execute(final List items) { - // We always need to use a SqlMapSession, as we need to pass a Spring-managed - // Connection (potentially transactional) in. This shouldn't be necessary if - // we run against a TransactionAwareDataSourceProxy underneath, but unfortunately - // we still need it to make iBATIS batch execution work properly: If iBATIS - // doesn't recognize an existing transaction, it automatically executes the - // batch for every single statement... - - SqlMapSession session = this.sqlMapClient.openSession(); - if (logger.isDebugEnabled()) { - logger.debug("Opened SqlMapSession [" + session + "] for iBATIS operation"); - } - Connection ibatisCon = null; - - try { - Connection springCon = null; - boolean transactionAware = (dataSource instanceof TransactionAwareDataSourceProxy); - - // Obtain JDBC Connection to operate on... - try { - ibatisCon = session.getCurrentConnection(); - if (ibatisCon == null) { - springCon = (transactionAware ? - dataSource.getConnection() : DataSourceUtils.doGetConnection(dataSource)); - session.setUserConnection(springCon); - if (logger.isDebugEnabled()) { - logger.debug("Obtained JDBC Connection [" + springCon + "] for iBATIS operation"); - } - } - else { - if (logger.isDebugEnabled()) { - logger.debug("Reusing JDBC Connection [" + ibatisCon + "] for iBATIS operation"); - } - } - } - catch (SQLException ex) { - throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", ex); - } - - // Execute given callback... - try { - session.startBatch(); - for (T item : items) { - session.update(statementId, item); - } - try { - return session.executeBatchDetailed(); - } catch (BatchException e) { - throw e.getBatchUpdateException(); - } - } - catch (SQLException ex) { - SQLExceptionTranslator sqlStateSQLExceptionTranslator; - - if(dataSource != null) { - sqlStateSQLExceptionTranslator = new SQLStateSQLExceptionTranslator(); - } else { - sqlStateSQLExceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(dataSource); - } - - throw sqlStateSQLExceptionTranslator.translate("SqlMapClient operation", null, ex); - } - - // Processing finished - potentially session still to be closed. - } - finally { - // Only close SqlMapSession if we know we've actually opened it - // at the present level. - if (ibatisCon == null) { - session.close(); - } - } - } -} diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java deleted file mode 100644 index fbf621080..000000000 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/IbatisPagingItemReader.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright 2006-2014 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.batch.item.database; - -import com.ibatis.sqlmap.client.SqlMapClient; -import com.ibatis.sqlmap.client.SqlMapSession; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.jdbc.CannotGetJdbcConnectionException; -import org.springframework.jdbc.datasource.DataSourceUtils; -import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; -import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator; -import org.springframework.jdbc.support.SQLExceptionTranslator; -import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator; -import org.springframework.util.Assert; -import org.springframework.util.ClassUtils; - -import javax.sql.DataSource; -import java.sql.Connection; -import java.sql.SQLException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; - -/** - *

- * {@link org.springframework.batch.item.ItemReader} for reading database - * records using iBATIS in a paging fashion. - *

- * - *

- * It executes the query specified as the {@link #setQueryId(String)} to - * retrieve requested data. The query is executed using paged requests of a size - * specified in {@link #setPageSize(int)}. Additional pages are requested when - * needed as {@link #read()} method is called, returning an object corresponding - * to current position. Some standard query parameters are provided by the - * reader and the SQL in the named query must use some or all of these parameters - * (depending on the SQL variant) to construct a result set of the required - * size. The parameters are:

- *
    - *
  • _page: the page number to be read (starting at 0)
  • - *
  • _pagesize: the size of the pages, i.e. the number of rows to - * return
  • - *
  • _skiprows: the product of _page and - * _pagesize
  • - *
- *

- * Failure to write the correct platform-specific SQL often results in an - * infinite loop in the reader because it keeps asking for the next page and - * gets the same result set over and over. - *

- * - *

- * The performance of the paging depends on the iBATIS implementation. - * Setting a fairly large page size and using a commit interval that matches the - * page size should provide better performance. - *

- * - *

- * The implementation is thread-safe in between calls to - * {@link #open(ExecutionContext)}, but remember to use - * saveState=false if used in a multi-threaded client (no restart - * available). - *

- * - *

Note: This reader was refactored as part of Spring Batch 3.0 to use the iBatis - * APIs directly instead of using Spring's SqlMapClientTemplate as part of the upgrade to - * support Spring 4.

- - * @author Thomas Risberg - * @author Dave Syer - * @author Michael Minella - * @since 2.0 - * @deprecated as of Spring Batch 3.0, in favor of the native Spring Batch support - * in the MyBatis follow-up project (http://mybatis.github.io/spring/) - */ -@Deprecated -public class IbatisPagingItemReader extends AbstractPagingItemReader { - - private SqlMapClient sqlMapClient; - - private String queryId; - - private Map parameterValues; - - private DataSource dataSource; - - public IbatisPagingItemReader() { - setName(ClassUtils.getShortName(IbatisPagingItemReader.class)); - } - - public void setDataSource(DataSource dataSource) { - this.dataSource = dataSource; - } - - public void setSqlMapClient(SqlMapClient sqlMapClient) { - this.sqlMapClient = sqlMapClient; - } - - public void setQueryId(String queryId) { - this.queryId = queryId; - } - - /** - * The parameter values to be used for the query execution. - * - * @param parameterValues the values keyed by the parameter named used in - * the query string. - */ - public void setParameterValues(Map parameterValues) { - this.parameterValues = parameterValues; - } - - /** - * Check mandatory properties. - * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() - */ - @Override - public void afterPropertiesSet() throws Exception { - super.afterPropertiesSet(); - Assert.notNull(sqlMapClient); - Assert.notNull(queryId); - } - - @Override - protected void doReadPage() { - Map parameters = new HashMap(); - if (parameterValues != null) { - parameters.putAll(parameterValues); - } - parameters.put("_page", getPage()); - parameters.put("_pagesize", getPageSize()); - parameters.put("_skiprows", getPage() * getPageSize()); - if (results == null) { - results = new CopyOnWriteArrayList(); - } - else { - results.clear(); - } - results.addAll(execute(parameters)); - } - - @SuppressWarnings("unchecked") - private List execute(Map parameters) { - // We always need to use a SqlMapSession, as we need to pass a Spring-managed - // Connection (potentially transactional) in. This shouldn't be necessary if - // we run against a TransactionAwareDataSourceProxy underneath, but unfortunately - // we still need it to make iBATIS batch execution work properly: If iBATIS - // doesn't recognize an existing transaction, it automatically executes the - // batch for every single statement... - - SqlMapSession session = this.sqlMapClient.openSession(); - if (logger.isDebugEnabled()) { - logger.debug("Opened SqlMapSession [" + session + "] for iBATIS operation"); - } - Connection ibatisCon = null; - - try { - Connection springCon = null; - boolean transactionAware = (dataSource instanceof TransactionAwareDataSourceProxy); - - // Obtain JDBC Connection to operate on... - try { - ibatisCon = session.getCurrentConnection(); - if (ibatisCon == null) { - springCon = (transactionAware ? - dataSource.getConnection() : DataSourceUtils.doGetConnection(dataSource)); - session.setUserConnection(springCon); - if (logger.isDebugEnabled()) { - logger.debug("Obtained JDBC Connection [" + springCon + "] for iBATIS operation"); - } - } - else { - if (logger.isDebugEnabled()) { - logger.debug("Reusing JDBC Connection [" + ibatisCon + "] for iBATIS operation"); - } - } - } - catch (SQLException ex) { - throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", ex); - } - - // Execute given callback... - try { - return session.queryForList(queryId, parameters); - } - catch (SQLException ex) { - SQLExceptionTranslator sqlStateSQLExceptionTranslator; - - if(dataSource != null) { - sqlStateSQLExceptionTranslator = new SQLStateSQLExceptionTranslator(); - } else { - sqlStateSQLExceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(dataSource); - } - - throw sqlStateSQLExceptionTranslator.translate("SqlMapClient operation", null, ex); - } - finally { - try { - if (springCon != null) { - if (transactionAware) { - springCon.close(); - } - else { - DataSourceUtils.doReleaseConnection(springCon, dataSource); - } - } - } - catch (Throwable ex) { - logger.debug("Could not close JDBC Connection", ex); - } - } - - // Processing finished - potentially session still to be closed. - } - finally { - // Only close SqlMapSession if we know we've actually opened it - // at the present level. - if (ibatisCon == null) { - session.close(); - } - } - } - - @Override - protected void doJumpToPage(int itemIndex) { - } - -} diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisBatchItemWriterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisBatchItemWriterTests.java deleted file mode 100644 index abd8beb27..000000000 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisBatchItemWriterTests.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright 2006-2008 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.item.database; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.Collections; -import java.util.List; - -import javax.sql.DataSource; - -import org.junit.Before; -import org.junit.Test; -import org.springframework.dao.EmptyResultDataAccessException; - -import com.ibatis.sqlmap.client.SqlMapClient; -import com.ibatis.sqlmap.client.SqlMapSession; -import com.ibatis.sqlmap.engine.execution.BatchResult; - -/** - * @author Thomas Risberg - * @author Will Schipp - */ -@SuppressWarnings("deprecation") -public class IbatisBatchItemWriterTests { - - private IbatisBatchItemWriter writer = new IbatisBatchItemWriter(); - - private DataSource ds; - - private SqlMapClient smc; - - private String statementId = "updateFoo"; - - @SuppressWarnings("unused") - private class Foo { - private Long id; - private String bar; - - public Foo(String bar) { - this.id = 1L; - this.bar = bar; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getBar() { - return bar; - } - - public void setBar(String bar) { - this.bar = bar; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof Foo)) { - return false; - } - Foo compare = (Foo) obj; - if (this.bar.equals(compare.getBar())) { - return true; - } - return false; - } - - @Override - public int hashCode() { - return bar.hashCode(); - } - - } - - @Before - public void setUp() throws Exception { - smc = mock(SqlMapClient.class); - ds = mock(DataSource.class); - writer.setStatementId(statementId); - writer.setSqlMapClient(smc); - writer.setDataSource(ds); - writer.afterPropertiesSet(); - } - - /** - * Test method for - * {@link org.springframework.batch.item.database.JdbcBatchItemWriter#afterPropertiesSet()} - * . - * @throws Exception - */ - @Test - public void testAfterPropertiesSet() throws Exception { - writer = new IbatisBatchItemWriter(); - try { - writer.afterPropertiesSet(); - fail("Expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { - // expected - String message = e.getMessage(); - assertTrue("Message does not contain 'SqlMapClient'.", message.indexOf("SqlMapClient") >= 0); - } - writer.setSqlMapClient(smc); - try { - writer.afterPropertiesSet(); - fail("Expected IllegalArgumentException"); - } - catch (IllegalArgumentException e) { - // expected - String message = e.getMessage(); - assertTrue("Message does not contain 'statementId'.", message.indexOf("statementId") >= 0); - } - writer.setStatementId("statementId"); - writer.afterPropertiesSet(); - } - - @Test - public void testWriteAndFlush() throws Exception { - SqlMapSession sms = mock(SqlMapSession.class); - when(smc.openSession()).thenReturn(sms); - sms.close(); - when(sms.getCurrentConnection()).thenReturn(null); - sms.setUserConnection(null); - sms.startBatch(); - when(sms.update("updateFoo", new Foo("bar"))).thenReturn(-2); - List results = Collections.singletonList(new BatchResult("updateFoo", "update foo")); - results.get(0).setUpdateCounts(new int[] {1}); - when(sms.executeBatchDetailed()).thenReturn(results); - writer.write(Collections.singletonList(new Foo("bar"))); - } - - @Test - public void testWriteAndFlushWithEmptyUpdate() throws Exception { - SqlMapSession sms = mock(SqlMapSession.class); - when(smc.openSession()).thenReturn(sms); - sms.close(); - when(sms.getCurrentConnection()).thenReturn(null); - sms.setUserConnection(null); - sms.startBatch(); - when(sms.update("updateFoo", new Foo("bar"))).thenReturn(1); - List results = Collections.singletonList(new BatchResult("updateFoo", "update foo")); - results.get(0).setUpdateCounts(new int[] {0}); - when(sms.executeBatchDetailed()).thenReturn(results); - try { - writer.write(Collections.singletonList(new Foo("bar"))); - fail("Expected EmptyResultDataAccessException"); - } - catch (EmptyResultDataAccessException e) { - // expected - String message = e.getMessage(); - assertTrue("Wrong message: " + message, message.indexOf("did not update") >= 0); - } - } - - @Test - public void testWriteAndFlushWithFailure() throws Exception { - final RuntimeException ex = new RuntimeException("ERROR"); - SqlMapSession sms = mock(SqlMapSession.class); - when(smc.openSession()).thenReturn(sms); - sms.close(); - when(sms.getCurrentConnection()).thenReturn(null); - sms.setUserConnection(null); - sms.startBatch(); - when(sms.update("updateFoo", new Foo("bar"))).thenThrow(ex); - try { - writer.write(Collections.singletonList(new Foo("bar"))); - fail("Expected RuntimeException"); - } - catch (RuntimeException e) { - assertEquals("ERROR", e.getMessage()); - } - } - -} diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java deleted file mode 100644 index 6c267cd84..000000000 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderAsyncTests.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2009-2014 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.item.database; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.CompletionService; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorCompletionService; -import java.util.concurrent.Executors; - -import javax.sql.DataSource; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.batch.item.sample.Foo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.io.ClassPathResource; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.jdbc.JdbcTestUtils; - -import com.ibatis.sqlmap.client.SqlMapClient; -import com.ibatis.sqlmap.client.SqlMapClientBuilder; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = "JdbcPagingItemReaderCommonTests-context.xml") -@SuppressWarnings("deprecation") -public class IbatisPagingItemReaderAsyncTests { - - /** - * The number of items to read - */ - private static final int ITEM_COUNT = 10; - - /** - * The number of threads to create - */ - private static final int THREAD_COUNT = 3; - - private static Log logger = LogFactory.getLog(IbatisPagingItemReaderAsyncTests.class); - - @Autowired - private DataSource dataSource; - - private int maxId; - - @Before - public void init() { - JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); - maxId = jdbcTemplate.queryForObject("SELECT MAX(ID) from T_FOOS", Integer.class); - for (int i = maxId + 1; i <= ITEM_COUNT; i++) { - jdbcTemplate.update("INSERT into T_FOOS (ID,NAME,VALUE) values (?, ?, ?)", i, "foo" + i, i); - } - assertEquals(ITEM_COUNT, JdbcTestUtils.countRowsInTable(jdbcTemplate, "T_FOOS")); - } - - @After - public void destroy() { - JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); - jdbcTemplate.update("DELETE from T_FOOS where ID>?", maxId); - } - - @Test - public void testAsyncReader() throws Throwable { - List throwables = new ArrayList(); - int max = 10; - for (int i = 0; i < max; i++) { - try { - doTest(); - } - catch (Throwable e) { - throwables.add(e); - } - } - if (!throwables.isEmpty()) { - throw new IllegalStateException(String.format("Failed %d out of %d", throwables.size(), max), throwables - .get(0)); - } - } - - /** - * @throws Exception - * @throws InterruptedException - * @throws ExecutionException - */ - private void doTest() throws Exception, InterruptedException, ExecutionException { - final IbatisPagingItemReader reader = getItemReader(); - CompletionService> completionService = new ExecutorCompletionService>(Executors - .newFixedThreadPool(THREAD_COUNT)); - for (int i = 0; i < THREAD_COUNT; i++) { - completionService.submit(new Callable>() { - @Override - public List call() throws Exception { - List list = new ArrayList(); - Foo next = null; - do { - next = reader.read(); - Thread.sleep(10L); // try to make it fairer - logger.debug("Reading item: " + next); - if (next != null) { - list.add(next); - } - } while (next != null); - return list; - } - }); - } - int count = 0; - Set results = new HashSet(); - for (int i = 0; i < THREAD_COUNT; i++) { - List items = completionService.take().get(); - count += items.size(); - logger.debug("Finished items count: " + items.size()); - logger.debug("Finished items: " + items); - assertNotNull(items); - results.addAll(items); - } - assertEquals(ITEM_COUNT, count); - assertEquals(ITEM_COUNT, results.size()); - reader.close(); - } - - private IbatisPagingItemReader getItemReader() throws Exception { - SqlMapClient sqlMapClient = createSqlMapClient(); - - IbatisPagingItemReader reader = new IbatisPagingItemReader(); - reader.setQueryId("getPagedFoos"); - reader.setPageSize(2); - reader.setSqlMapClient(sqlMapClient); - reader.setSaveState(true); - reader.setDataSource(dataSource); - - reader.afterPropertiesSet(); - - return reader; - } - - private SqlMapClient createSqlMapClient() throws Exception { - return SqlMapClientBuilder.buildSqlMapClient(new ClassPathResource("ibatis-config.xml", getClass()).getInputStream()); - } - -} diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java deleted file mode 100644 index e3cbca6cd..000000000 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderCommonTests.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2008-2014 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.item.database; - -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.springframework.batch.item.ExecutionContext; -import org.springframework.batch.item.ItemReader; -import org.springframework.batch.item.sample.Foo; -import org.springframework.core.io.ClassPathResource; - -import com.ibatis.sqlmap.client.SqlMapClient; -import com.ibatis.sqlmap.client.SqlMapClientBuilder; - -@RunWith(JUnit4.class) -@SuppressWarnings("deprecation") -public class IbatisPagingItemReaderCommonTests extends AbstractDatabaseItemStreamItemReaderTests { - - @Override - protected ItemReader getItemReader() throws Exception { - SqlMapClient sqlMapClient = createSqlMapClient(); - - IbatisPagingItemReader reader = new IbatisPagingItemReader(); - reader.setQueryId("getPagedFoos"); - reader.setPageSize(2); - reader.setSqlMapClient(sqlMapClient); - reader.setDataSource(getDataSource()); - reader.setSaveState(true); - - reader.afterPropertiesSet(); - - return reader; - } - - private SqlMapClient createSqlMapClient() throws Exception { - return SqlMapClientBuilder.buildSqlMapClient(new ClassPathResource("ibatis-config.xml", getClass()).getInputStream()); - } - - @Override - protected void pointToEmptyInput(ItemReader tested) throws Exception { - IbatisPagingItemReader reader = (IbatisPagingItemReader) tested; - reader.close(); - - reader.setQueryId("getNoFoos"); - reader.afterPropertiesSet(); - - reader.open(new ExecutionContext()); - } - -} diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderParameterTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderParameterTests.java deleted file mode 100644 index a7a9dacd2..000000000 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/IbatisPagingItemReaderParameterTests.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2008-2014 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.item.database; - -import java.util.Collections; - -import org.junit.runner.RunWith; -import org.springframework.batch.item.sample.Foo; -import org.springframework.core.io.ClassPathResource; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import com.ibatis.sqlmap.client.SqlMapClient; -import com.ibatis.sqlmap.client.SqlMapClientBuilder; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = "/org/springframework/batch/item/database/data-source-context.xml") -public class IbatisPagingItemReaderParameterTests extends AbstractPagingItemReaderParameterTests { - - @Override - @SuppressWarnings("deprecation") - protected AbstractPagingItemReader getItemReader() throws Exception { - SqlMapClient sqlMapClient = createSqlMapClient(); - - IbatisPagingItemReader reader = new IbatisPagingItemReader(); - reader.setQueryId("getPagedFoosLimitAndUp"); - reader.setParameterValues(Collections.singletonMap("limit", 2)); - reader.setSqlMapClient(sqlMapClient); - reader.setDataSource(dataSource); - reader.setSaveState(true); - - reader.afterPropertiesSet(); - - return reader; - } - - private SqlMapClient createSqlMapClient() throws Exception { - SqlMapClient client = SqlMapClientBuilder.buildSqlMapClient(new ClassPathResource("ibatis-config.xml", getClass()).getInputStream()); - return client; - } -} diff --git a/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/ibatis-config.xml b/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/ibatis-config.xml deleted file mode 100644 index f23807357..000000000 --- a/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/ibatis-config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/ibatis-foo.xml b/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/ibatis-foo.xml deleted file mode 100644 index 7540d29a3..000000000 --- a/spring-batch-infrastructure/src/test/resources/org/springframework/batch/item/database/ibatis-foo.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - insert INTO T_WRITE_FOOS (ID, NAME, VALUE) VALUES (#id#, #name#, #value#) - - - - update T_WRITE_FOOS set NAME = #name#, VALUE = #value# where ID = #id# - - - - delete from T_WRITE_FOOS where ID = #id# - - - \ No newline at end of file diff --git a/spring-batch-samples/.springBeans b/spring-batch-samples/.springBeans index f5fbf33b3..477bf9450 100644 --- a/spring-batch-samples/.springBeans +++ b/spring-batch-samples/.springBeans @@ -43,7 +43,6 @@ src/main/resources/jobs/iosample/hibernate.xml src/main/resources/jobs/hibernateJob.xml src/main/resources/jobs/iosample/jpa.xml - src/main/resources/jobs/iosample/ibatis.xml src/test/resources/org/springframework/batch/sample/domain/trade/internal/JdbcCustomerDebitDaoTests-context.xml src/main/resources/jobs/loopFlowSample.xml src/test/resources/org/springframework/batch/sample/common/StagingItemReaderTests-context.xml @@ -429,19 +428,6 @@
- - - true - false - - src/main/resources/data-source-context.xml - src/main/resources/simple-job-launcher-context.xml - src/main/resources/org/springframework/batch/sample/config/common-context.xml - src/main/resources/jobs/iosample/ibatis.xml - - - - true diff --git a/spring-batch-samples/README.md b/spring-batch-samples/README.md index bf781bd9a..78cfb34b8 100644 --- a/spring-batch-samples/README.md +++ b/spring-batch-samples/README.md @@ -51,7 +51,6 @@ Job/Feature | delimited input | fixed-length input | xml input | :-------------------------- | :-------------: | :----------------: | :-------: | :-------------: | :-------------: | :--------------: | :-----------------: | :--------: | :-------: | :------------: | :--------: | :----------: delimited | x | | | | | | | x | | | | [fixedLength](#fixedLength) | | x | | | | | | | x | | | -[ibatis](#ibatis) | | | | | x | | | | | | x | [hibernate](#hibernate) | | | | | x | | | | | | x | [jdbcCursor](#jdbcCursor) | | | | | x | | | | | | x | jpa | | | | x | | | | | | | x | @@ -521,12 +520,6 @@ The output reliability and robustness are improved by the use of need to take control of it so that the skip and retry features provided by Spring Batch can work effectively. -### [Ibatis Sample](id:ibatis) - -The goal of this sample is to show the use of Ibatis as a query -mapping tool. Its features are similar to the Hibernate sample, but -it uses Ibatis to drive its input and output. - ### [Infinite Loop Sample](id:infiniteLoop) This sample has a single step that is an infinite loop, reading and diff --git a/spring-batch-samples/src/main/resources/ibatis-config.xml b/spring-batch-samples/src/main/resources/ibatis-config.xml deleted file mode 100644 index d038e54c5..000000000 --- a/spring-batch-samples/src/main/resources/ibatis-config.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - diff --git a/spring-batch-samples/src/main/resources/ibatis-customer-credit.xml b/spring-batch-samples/src/main/resources/ibatis-customer-credit.xml deleted file mode 100644 index eabd330a9..000000000 --- a/spring-batch-samples/src/main/resources/ibatis-customer-credit.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - update CUSTOMER set CREDIT = #credit# where NAME = #name# - - diff --git a/spring-batch-samples/src/main/resources/jobs/iosample/ibatis.xml b/spring-batch-samples/src/main/resources/jobs/iosample/ibatis.xml deleted file mode 100644 index 5f1f51f39..000000000 --- a/spring-batch-samples/src/main/resources/jobs/iosample/ibatis.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/IbatisFunctionalTests.java b/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/IbatisFunctionalTests.java deleted file mode 100644 index ef9be7f9c..000000000 --- a/spring-batch-samples/src/test/java/org/springframework/batch/sample/iosample/IbatisFunctionalTests.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2008-2009 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.batch.sample.iosample; - -import org.junit.runner.RunWith; -import org.springframework.batch.item.ItemReader; -import org.springframework.batch.sample.domain.trade.CustomerCredit; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = "/jobs/iosample/ibatis.xml") -public class IbatisFunctionalTests extends AbstractIoSampleTests { - - @Override - protected void pointReaderToOutput(ItemReader reader) { - // no-op - } - -} diff --git a/src/site/docbook/reference/appendix.xml b/src/site/docbook/reference/appendix.xml index fb1bbccd9..40b8ff538 100644 --- a/src/site/docbook/reference/appendix.xml +++ b/src/site/docbook/reference/appendix.xml @@ -73,15 +73,6 @@ Reads from a paginated HQL query - - IbatisPagingItemReader - - Reads via iBATIS based on a query. Pages - through the rows so that large datasets can be read without - running out of memory. See HOWTO - Read from a Database. This - ItemReader is now deprecated as of Spring Batch 3.0. - - ItemReaderAdapter @@ -236,13 +227,6 @@ to another item writer to do the actual writing. - - IbatisBatchItemWriter - - Writes items in a batch using the iBatis API's - directly. This ItemWriter is deprecated as of Spring Batch 3.0. - - ItemWriterAdapter diff --git a/src/site/docbook/reference/readersAndWriters.xml b/src/site/docbook/reference/readersAndWriters.xml index 1df2bd29c..8f5fa9dfa 100644 --- a/src/site/docbook/reference/readersAndWriters.xml +++ b/src/site/docbook/reference/readersAndWriters.xml @@ -2270,53 +2270,6 @@ itemReader.close(executionContext); entities read from the database for each query execution. -
- IbatisPagingItemReader - - This reader is deprecated as of Spring Batch 3.0. - - If you use IBATIS for your data access then you can use the - IbatisPagingItemReader which, as the name - indicates, is an implementation of a paging - ItemReader. IBATIS doesn't have direct support - for reading rows in pages but by providing a couple of standard - variables you can add paging support to your IBATIS queries. - - Here is an example of a configuration for a - IbatisPagingItemReader reading CustomerCredits - as in the examples above: - - <bean id="itemReader" class="org.spr...IbatisPagingItemReader"> - <property name="sqlMapClient" ref="sqlMapClient"/> - <property name="queryId" value="getPagedCustomerCredits"/> - <property name="pageSize" value="1000"/> -</bean> - - The IbatisPagingItemReader configuration - above references an IBATIS query called "getPagedCustomerCredits". - Here is an example of what that query should look like for - MySQL. - - <select id="getPagedCustomerCredits" resultMap="customerCreditResult"> - select id, name, credit from customer order by id asc LIMIT #_skiprows#, #_pagesize# -</select> - - The _skiprows and - _pagesize variables are provided by the - IbatisPagingItemReader and there is also a - _page variable that can be used if necessary. - The syntax for the paging queries varies with the database used. Here - is an example for Oracle (unfortunately we need to use CDATA for some - operators since this belongs in an XML document): - - <select id="getPagedCustomerCredits" resultMap="customerCreditResult"> - select * from ( - select * from ( - select t.id, t.name, t.credit, ROWNUM ROWNUM_ from customer t order by id - )) where ROWNUM_ <![CDATA[ > ]]> ( #_page# * #_pagesize# ) - ) where ROWNUM <![CDATA[ <= ]]> #_pagesize# -</select> -