当ddl-generation是create-or-extend-tables时,hsqldb无法使用eclipselink

时间:2013-06-27 05:27:14

标签: java-ee eclipselink hsqldb

当我将ddl-generation设置为drop-and-create-tables时,一切都很好。但是当它被设置为create-or-extend-tables时,我得到了这个:

Internal Exception: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: PERSON_ID_SEQ

以下是我如何设置它:

的persistence.xml

<persistence ...>
  <persistence-unit name="persistencetest">
    <properties>
      <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />

      <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:test-db" />

      <property name="javax.persistence.jdbc.user" value="sa" />
      <property name="javax.persistence.jdbc.password" value="" />

      <property name="eclipselink.ddl-generation" value="create-or-extend-tables" />
      <property name="eclipselink.ddl-generation.output-mode" value="database" />
    </properties>

    <class>test.Person</class>
  </persistence-unit>
</persistence>

Person.java

@Entity
public class Person
{
  @Id
  @SequenceGenerator(name = "id_seq", sequenceName = "PERSON_ID_SEQ")
  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_seq")
  private long id;

  ...
}

的pom.xml

...
<dependency>
  <groupId>org.glassfish.extras</groupId>
  <artifactId>glassfish-emdedded-all</artifactId>
  <version>3.1</version>
  <scope>test</scope>
</dependency>

<dependency>
  <groupId>org.eclipse.persistence</groupId>
  <artifactId>org.eclipse.persistence.jpa</artifactId>
  <version>2.4.1</version>
  <scope>provided</scope>
</dependency>

<dependency>
  <groupId>org.hsqldb</groupId>
  <artifactId>hsqldb</artifactId>
  <version>2.2.9</version>
</dependency>
...

那么什么导致create-or-extend-tables失败而drop-and-create-tables运行正常呢?

1 个答案:

答案 0 :(得分:0)

是错误,还是仅记录了警告?如果没有错误发生,那只是一个警告,您可以忽略它。只是测试看看序列是否存在。

如果出现错误,请包含完整的异常堆栈和SQL日志。