我正在尝试为 H2 导入 sql 脚本。此脚本由 spring-batch 提供,用于存储作业元数据。当我直接在 H2 控制台中执行此脚本时,我没有语法错误,但我在初始化阶段引用了要导入的 Hibernate/JPA 中的相同脚本,我得到了这个异常:
org.hibernate.tool.hbm2ddl.ImportScriptException: Error during statement execution (file: 'org/springframework/batch/core/schema-h2.sql'): CREATE TABLE BATCH_JOB_INSTANCE (
....
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "CREATE TABLE BATCH_JOB_INSTANCE ("; expected "identifier"; SQL statement:
CREATE TABLE BATCH_JOB_INSTANCE ( [42001-171]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) ~[h2-1.3.171.jar:1.3.171]
at org.h2.message.DbException.get(DbException.java:169) ~[h2-1.3.171.jar:1.3.171]
at org.h2.message.DbException.getSyntaxError(DbException.java:194) ~[h2-1.3.171.jar:1.3.171]
我正在使用 hbm2ddl 导入 sql 文件:
jpaProperties.setProperty("hibernate.connection.driver_class", "org.h2.Driver");
jpaProperties.setProperty("hibernate.dialect", H2Dialect.class.getName());
jpaProperties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
jpaProperties.setProperty("hibernate.hbm2ddl.import_files",
"org/springframework/batch/core/schema-drop-h2.sql,org/springframework/batch/core/schema-h2.sql");
知道如何解决这个问题吗?