3

我有 EclipseLink 2.4 的 JPA2,我正在尝试使用 HSQLDB 实现一个内存数据库。我已经能够使用创建 hsqldb 的文件实现

jdbc:hsqldb:file:./databases/test;shutdown=true;files_readonly=true

但是当我尝试使用时jdbc:hsqldb:mem:tableName,我收到以下消息:


堆栈跟踪:

javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse   
Persistence Services - 2.4.0.v20120608-r11652):  
  org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: user lacks privilege or object
  not found: EFFECTIVITY

Error Code: -5501
Call: INSERT INTO EFFECTIVITY (HULL) VALUES (?)
bind => [1 parameter bound]
Query: InsertObjectQuery(101)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush
       (EntityManagerImpl.java:804)
at com.gdeb.touchtable.db.TestJPAEntities.testTTTouch(TestJPAEntities.java:93)
..............
Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found:
 EFFECTIVITY
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.SchemaManager.getTable(Unknown Source)
at org.hsqldb.ParserDQL.readTableName(Unknown Source)
at org.hsqldb.ParserDQL.readRangeVariableForDataChange(Unknown Source)
at org.hsqldb.ParserDML.compileInsertStatement(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)
... 63 more

根据我的阅读,数据模型应该是自动生成的,但我只看到了 Hibernate 的示例。有没有办法链接 JPA 数据模型并使用 HSQLDB 的内存模式创建它?

4

1 回答 1

3

如果缺少表,则需要将 eclipselink.ddl-generation 属性设置为“create-tables”,以让 Eclipselink 为您创建它们。此处发布了一个示例:http ://wiki.eclipse.org/EclipseLink/Examples/JPA/DDL

于 2012-11-02T12:57:00.570 回答