我正在尝试导入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");
你有什么想法可以解决这个问题吗?