我正在尝试为我的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)");
我做错了什么?
谢谢!
答案 0 :(得分: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
);