Skip to content

Clarify SQL Server < 2012 support and document table-based incrementer workaround #5035

@i3months

Description

@i3months

Expected Behavior

The reference documentation should clearly explain that SQL Server 2012 or later is required
because Spring Batch 5 uses database sequences (SELECT NEXT VALUE FOR ...) in the default schema.

It should also provide a short "Legacy SQL Server" note describing how to use
a table-based incrementer (SqlServerMaxValueIncrementer) as a workaround for
older SQL Server versions (such as 2005) that do not support sequences.

For example:

Note: SQL Server 2012+ is required for the default schema.
For older versions without sequence support, create dedicated sequence tables
(e.g., BATCH_JOB_SEQ) and configure SqlServerMaxValueIncrementer to use them.


Current Behavior

When using Spring Batch 5.x with SQL Server 2005 or any version without sequence support,
the framework fails to initialize the job repository with the following error:

org.springframework.dao.DataAccessResourceFailureException: Could not obtain sequence value

This happens because the current implementation (SqlServerSequenceMaxValueIncrementer)
executes the SELECT NEXT VALUE FOR ... query, which is not supported prior to SQL Server 2012.
There is no fallback or documentation describing this limitation.


Context

I encountered this issue while using Spring Batch with SQL Server 2005.
Older SQL Server versions are still found in legacy enterprise systems, and developers
might face this issue without understanding why it occurs.

By documenting the limitation and providing a workaround,
users can manually configure Spring Batch to work with legacy SQL Server versions
(using table-based incrementers) instead of being blocked by the sequence requirement.

I have already implemented this workaround successfully in my environment,
and I would be happy to contribute a documentation PR with examples
(DDL + configuration snippet) to help others avoid the same problem.


Contributor Note

I'm willing to work on this improvement myself and submit a pull request
to add the proposed clarification and example to the reference documentation.

Thanks for considering this!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions