当我将 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 运行良好?