我正在使用JPA和Hibernate / Oracle,并且在测试阶段使用HSQL。我已按照此SO question中的规定定义了数据源,但没有帮助。
注意:我正在运行Liquibase脚本来生成架构。
@Id
@SequenceGenerator(name="DM_UW_REF_RULES_RSLT_UWSCOREID_GENERATOR", sequenceName="SEQ_UW_SCORE_ID")
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="DM_UW_REF_RULES_RSLT_UWSCOREID_GENERATOR")
@Column(name="UW_SCORE_ID")
HSQL数据源和entityManagerFactory bean定义如下
dmDs(BasicDataSource) {
driverClassName = 'org.hsqldb.jdbc.JDBCDriver'
url = 'jdbc:hsqldb:mem:testdb;sql.syntax_ora=true'
username = 'sa'
password = ''
}
entityManagerFactory(LocalContainerEntityManagerFactoryBean) {
dataSource = ref('dmDs')
packagesToScan = "com.abc.dm.model"
jpaVendorAdapter = ref('hibjpa')
jpaPropertyMap = ["connection.driver_class": "org.hsqldb.jdbc.JDBCDriver", 'hibernate.dialect':'org.hibernate.dialect.HSQLDialect','show_sql': "true"]
}
异常追踪:
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: SEQ_UW_SCORE_ID.NEXTVAL
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.ExpressionColumn.checkColumnsResolved(Unknown Source)
at org.hsqldb.QueryExpression.resolve(Unknown Source)
at org.hsqldb.ParserDQL.compileCursorSpecification(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
at org.hsqldb.StatementManager.compile(Unknown Source)
at org.hsqldb.Session.execute(Unknown Source)
答案 0 :(得分:0)
您似乎缺少用于表生成的hibernate.hbm2ddl.auto属性。
您也可以使用通用的javax.persistence.schema-generation.database.action属性。