簡體   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