繁体   English   中英

JPA的持久性表示描述符中不存在实体

[英]Persistence with JPA says entity is not present in descriptor

我们在尝试使用数据库实现阶梯游戏应用程序时遇到了问题。 我们有一个名为“ Spill”的实体,该实体与另一个名为“ Brett”的实体具有ManyToOne关系。

但是,当持久性尝试将实体映射到数据库时,似乎找不到它们。

Exception [EclipseLink-93] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: The table [brett] is not present in this descriptor.
Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Exception [EclipseLink-41] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A non-read-only mapping must be defined for the sequence number field.
Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

它们都完全在persistence.xml文件中,并且程序似乎可以很好地连接到数据库。 我们已经明确给出了名称和架构名称:

@Entity
@Table(name="spill",schema = "stigespill")

在两个班上。

洒:

@Entity
@Table(name="spill",schema = "stigespill")
public class Spill {

  // FELTVARIABLER
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Integer spillid;

  private Integer ferdig;
  private Timestamp dato;

  @OneToMany(mappedBy = "spill" , cascade = CascadeType.ALL)
  private List<Spiller> spillere; // TODO Skiftet fra Queue til ArrayList

  @OneToMany(mappedBy = "spill" , cascade = CascadeType.ALL)
  private List<Trekk> trekklog;

  @ManyToOne( cascade = CascadeType.ALL)
  @JoinColumn(name = "brett", referencedColumnName="brettid", insertable = false, updatable = false)
  private Brett brett;
}

布雷特:

@Entity
@Table(name = "brett", schema = "stigespill")
public class Brett {

  // FELTVARIABLER
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  private Integer brettid;

  @OneToMany(mappedBy = "brett", cascade = CascadeType.ALL)
  private List<Rute> ruter;
}

我们一直在搜索网络,并试图在最近的几个小时内解决这个问题,但是找不到解决方案。

完整的控制台日志:

[EL Info]: server: 2016-04-26 15:58:15.551--ServerSession(1348949648)--Detected server platform: org.eclipse.persistence.platform.server.NoServerPlatform.
[EL Warning]: metadata: 2016-04-26 15:58:15.876--ServerSession(1348949648)--The reference column name [spillid] mapped on the element [field spill] does not correspond to a valid id or basic field/column on the mapping reference. Will use referenced column name as provided.
[EL Info]: server: 2016-04-26 15:58:15.951--ServerSession(1348949648)--Detected server platform: org.eclipse.persistence.platform.server.NoServerPlatform.
[EL Info]: 2016-04-26 15:58:16.63--ServerSession(1348949648)--EclipseLink, version: Eclipse Persistence Services - 2.6.0.v20150309-bf26070
[EL Severe]: 2016-04-26 15:58:17.084--ServerSession(1348949648)--Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.IntegrityException

Descriptor Exceptions:

Exception [EclipseLink-93] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The table [brett] is not present in this descriptor. Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Exception [EclipseLink-41] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Runtime Exceptions:

[EL Info]: connection: 2016-04-26 15:58:17.087--ServerSession(1348949648)--/file:/Users/../Stigespill/bin/_eclipselink logout successful [EL Severe]: ejb: 2016-04-26 15:58:17.091--ServerSession(1348949648)--Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.IntegrityException

Descriptor Exceptions:

Exception [EclipseLink-93] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The table [brett] is not present in this descriptor. Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Exception [EclipseLink-41] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Runtime Exceptions:

Exception in thread "main" javax.persistence.PersistenceException: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Deployment of PersistenceUnit [eclipselink] failed. Close all factories for this PersistenceUnit. Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.IntegrityException

Descriptor Exceptions:

Exception [EclipseLink-93] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The table [brett] is not present in this descriptor. Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Exception [EclipseLink-41] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Runtime Exceptions:

at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createDeployFailedPersistenceException(EntityManagerSetupImpl.java:866)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:806)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:205)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:305)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:337)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:303)
at no.hib.dat101.database.Emh.slettAlt(Emh.java:137)
at no.hib.dat101.main.Main_Tekst.main(Main_Tekst.java:12)

Caused by: Exception [EclipseLink-28019] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.EntityManagerSetupException Exception Description: Deployment of PersistenceUnit [eclipselink] failed. Close all factories for this PersistenceUnit. Internal Exception: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.IntegrityException

Descriptor Exceptions:

Exception [EclipseLink-93] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The table [brett] is not present in this descriptor. Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Exception [EclipseLink-41] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Runtime Exceptions:

at org.eclipse.persistence.exceptions.EntityManagerSetupException.deployFailed(EntityManagerSetupException.java:239)
... 8 more

Caused by: Exception [EclipseLink-0] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.IntegrityException

Descriptor Exceptions:

Exception [EclipseLink-93] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException Exception Description: The table [brett] is not present in this descriptor. Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Exception [EclipseLink-41] (Eclipse Persistence Services - 2.6.0.v20150309-bf26070): org.eclipse.persistence.exceptions.DescriptorException Exception Description: A non-read-only mapping must be defined for the sequence number field. Descriptor: RelationalDescriptor(no.hib.dat101.entities.Spill --> [DatabaseTable(stigespill.spill)])

Runtime Exceptions:

at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:701) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:637) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:568) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:804) at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:748) at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:253) at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:728) ... 6 more<code>

在一种情况下,为了使@Table正常工作,我还必须添加catalog 另外,我不得不在@Entity命名该表。 尝试:

@Entity(name="spill")
@Table(name="spill",schema = "stigespill", catalog="public")

等等

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM