1

我正在尝试为我的 Spring-Batch 应用程序运行 JUnit 测试类。我必须创建以下表格:http ://static.springsource.org/spring-batch/reference/html/metaDataSchema.html 。我在初始化数据库脚本中创建它们,包括以下内容:

CREATE SEQUENCE BATCH_STEP_EXECUTION_SEQ;
CREATE SEQUENCE BATCH_JOB_EXECUTION;
CREATE SEQUENCE BATCH_JOB_SEQ;

所有序列和表格的创建都没有产生任何错误。但是在执行我的 JUnit 测试时,我收到以下错误:

org.springframework.dao.DataAccessResourceFailureException: Could not obtain identity(); nested exception is java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: BATCH_JOB_SEQ
    at org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer.getNextKey(HsqlMaxValueIncrementer.java:119)

这是在类 HsqlMaxValueIncrementer 运行时引起的:

stmt.executeUpdate("insert into " + getIncrementerName() + " values(null)");

我究竟做错了什么?

谢谢!!

4

1 回答 1

2

对于 HSQLDB,3 个表需要 ID 字段。

CREATE TABLE BATCH_STEP_EXECUTION_SEQ (
           ID BIGINT IDENTITY
);
CREATE TABLE BATCH_JOB_EXECUTION_SEQ (
           ID BIGINT IDENTITY
);
CREATE TABLE BATCH_JOB_SEQ (
           ID BIGINT IDENTITY
);

参考:https ://github.com/SpringSource/spring-batch/blob/master/spring-batch-core/src/main/resources/org/springframework/batch/core/schema-hsqldb.sql

于 2013-02-19T11:48:56.787 回答