3

当我将 ddl-generation 设置为 drop-and-create-tables 时,一切都很好。但是当它设置为创建或扩展表时,我得到了这个:

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

这是我的设置方式:

持久性.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>

人.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 运行良好?

4

1 回答 1

0

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

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

于 2013-07-02T14:39:33.600 回答