Example usage for org.springframework.batch.item.database AbstractCursorItemReader VALUE_NOT_SET

List of usage examples for org.springframework.batch.item.database AbstractCursorItemReader VALUE_NOT_SET

Introduction

In this page you can find the example usage for org.springframework.batch.item.database AbstractCursorItemReader VALUE_NOT_SET.

Prototype

int VALUE_NOT_SET

To view the source code for org.springframework.batch.item.database AbstractCursorItemReader VALUE_NOT_SET.

Click Source Link

Usage

From source file:org.springframework.xd.jdbc.NamedColumnJdbcItemReaderFactory.java

@Override
public void afterPropertiesSet() throws Exception {
    if (!StringUtils.hasText(sql)) {
        Assert.hasText(tableName, "tableName must be set");
        Assert.hasText(columnNames, "columns must be set");

        String sql;/*  w ww .  j a  v  a 2 s.c o  m*/
        if (StringUtils.hasText(partitionClause)) {
            sql = "SELECT " + columnNames + " FROM " + tableName + " " + partitionClause;
        } else {
            sql = "SELECT " + columnNames + " FROM " + tableName;
        }
        log.info("Setting SQL to: " + sql);
        setSql(sql);
    } else if (StringUtils.hasText(columnNames) || StringUtils.hasText(tableName)) {
        log.warn("You must set either the 'sql' property or 'tableName' and 'columns'.");
    }

    DatabaseType type = DatabaseType.fromMetaData(dataSource);

    switch (type) {
    case MYSQL:
        fetchSize = Integer.MIN_VALUE;
        // MySql doesn't support getRow for a streaming cursor
        verifyCursorPosition = false;
        break;
    case SQLITE:
        fetchSize = AbstractCursorItemReader.VALUE_NOT_SET;
        break;
    default:
        // keep configured fetchSize
    }

    reader = new NamedColumnJdbcItemReader();
    reader.setSql(sql);
    reader.setFetchSize(fetchSize);
    reader.setDataSource(dataSource);
    reader.setVerifyCursorPosition(verifyCursorPosition);
    reader.afterPropertiesSet();

    initialized = true;
}