我使用OpenJPA的2.2.2我的persistence.xml就像如下为什么虽然我不指定它产生table_seq
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="PU" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<class>package.User</class>
<properties>
<property name="openjpa.ConnectionURL" value="jdbc:postgresql://localhost:5432/postgres" />
<property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver" />
<property name="openjpa.ConnectionUserName" value="postgres" />
<property name="openjpa.ConnectionPassword" value="****" />
<property name="openjpa.DynamicEnhancementAgent" value="true" />
<property name="openjpa.RuntimeUnenhancedClasses" value="supported" />
<property name="openjpa.Log" value="SQL=TRACE" />
<property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=72, PrintParameters=true, MaxActive=10, MaxIdle=5, MinIdle=2, MaxWait=60000" />
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema" />
</properties>
</persistence-unit>
和User.java
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private long id;
...
尽管seq_table被创建并且序列(本地一个)不是。如何解决它使用内置序列我正在使用postgreSQL。另外我不明白为什么每个PK在上面使用时都是前一个的+50。
请不要将RuntimeUtenhancedClass设置为受支持。从长远来看,如果您阅读OpenJPA网页中关于增强功能的介绍,那么您将会更加高兴。DynamicEnhancementAgent很好,但不是长期保存的内容。 http://openjpa.apache.org/entity-enhancement.html – Rick
@Rick 我试了一次。经过一个星期,通过无法读取的文档,我放弃了。这对我来说太难了,所以我使用它,因为它是WORK。 – abc
我100%理解......当您遇到由于使用该功能导致的错误时,请不要不高兴。 – Rick