我在Java中有一个REST API应用程序,我正在使用EclipseLink。一切都很好,但在代码提交后,当我想在本地机器上运行我的应用程序时,我收到此错误。错误是:
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
这是我的 Contract.class :
@Entity
@Table(name = "Contract")
public class Contract implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long ID;
@Temporal(TemporalType.DATE)
@Column(name = "CONTRACT_DATE")
private Date contractDate;
@ManyToOne
@JoinColumn(name = "INSURED_PERSON_ID")
private InsuredPerson person;
@OneToOne
@JoinColumn(name = "CURRENCY_ID")
private ReferenceData currency;
@OneToMany(mappedBy = "contract")
private Set<PaymentGraph> paymentGraphs;
@OneToMany(mappedBy = "contract")
private Set<Payment> payments;
private Long franchise;
private Long tariff;
@Column(name = "COMMISSION_AMOUNT")
private BigDecimal commissionAmount;
@Column(name = "BROKER_COMMISSION")
private BigDecimal brokerCommission;
@Column(name = "IS_COMMISSION_OFFICIAL")
private Boolean isCommissionOfficial;
@Column(name = "COMMISSION_PAYMENT_TYPE")
private String commissionPaymentType;
@Column(name = "COMMISSION_ACT")
private String commissionAct;
@Column(name = "IS_COMMISSION_PAID")
private Boolean isCommissionPaid;
private String note;
private String type;
@ManyToOne
@JoinColumn(name = "CONTRACT_COMPANY_ID")
private ReferenceData company;
@Temporal(TemporalType.DATE)
@Column(name = "INSURANCE_START")
private Date insuranceStart;
@Temporal(TemporalType.DATE)
@Column(name = "INSURANCE_END")
private Date insuranceEnd;
private BigDecimal amount;
private BigDecimal price;
@Temporal(TemporalType.DATE)
@Column(name = "START_DATE")
private Date startDate;
@Temporal(TemporalType.DATE)
@Column(name = "FINISH_DATE")
private Date finishDate;
private String policy;
@Column(name = "INSURANCE_PRICE_AZN")
private BigDecimal insurancePriceAZN;
@Column(name = "PROFIT_SHEBEKE")
private BigDecimal profitShebeke;
private String curator;
这是我的 PaymentGraph.class :
@Entity
@Table(name = "PaymentGraph")
public class PaymentGraph implements java.io.Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long ID;
@Column(name = "PAYMENT_PAID")
private BigDecimal paymentPaid;
@Column(name = "PAYMENT_REMAINING")
private BigDecimal paymentRemaining;
@ManyToOne
@JoinColumn(name = "CONTRACT_ID")
private Contract contract;
@Temporal(TemporalType.DATE)
@Column(name = "PAYMENT_PAID_DATE")
private Date paymentPaidDate;
@Temporal(TemporalType.DATE)
@Column(name = "START_DATE")
private Date startDate;
@Temporal(TemporalType.DATE)
@Column(name = "FINISH_DATE")
private Date finishDate;
@Column(name = "IS_PAID")
private Boolean isPaid;
这是我的 persistence.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="insurance" transaction-type="RESOURCE_LOCAL">
<class>org.simberg.datastructures.entity.Contract</class>
<class>org.simberg.datastructures.entity.InsuredPerson</class>
<class>org.simberg.datastructures.entity.Payment</class>
<class>org.simberg.datastructures.entity.PaymentGraph</class>
<class>org.simberg.datastructures.entity.ReferenceData</class>
<class>org.simberg.datastructures.entity.User</class>
<class>org.simberg.datastructures.entity.Address</class>
<properties>
<!--<property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver" />-->
<property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" />
<!--<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/insurance?useSSL=false" />-->
<property name="javax.persistence.jdbc.url" value="jdbc:derby:/Users/danyalov/Development/Java/insuranceDB;create=true" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
<!-- EclipseLink should create the entity schema automatically -->
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>
</persistence>
最后完整错误堆栈:
6655 [main] ERROR org.simberg.datastructures.entity.ReferenceData -
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@6ce253f1
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [insurance] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@6ce253f1
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [insurance] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at org.simberg.configuration.EntityManagerConfigurator.getFactory(EntityManagerConfigurator.java:27)
at org.simberg.datastructures.entity.ReferenceData.initDummyData(ReferenceData.java:130)
at org.simberg.application.App.main(App.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [insurance] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1950)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1941)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:96)
... 11 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [insurance] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:230)
... 15 more
Caused by: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
at org.eclipse.persistence.exceptions.ValidationException.nonEntityTargetInRelationship(ValidationException.java:1378)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.RelationshipAccessor.getReferenceDescriptor(RelationshipAccessor.java:568)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processForeignKeyRelationship(ObjectAccessor.java:659)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processOwningMappingKeys(ObjectAccessor.java:733)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ManyToOneAccessor.process(ManyToOneAccessor.java:123)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processOwningRelationshipAccessors(MetadataProject.java:1578)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1831)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:580)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:585)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1865)
... 13 more
Insurance Project Started...
6721 [main] ERROR org.simberg.datastructures.entity.ReferenceData -
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@6ce253f1
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [insurance] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
Local Exception Stack:
Exception [EclipseLink-30005] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.PersistenceUnitLoadingException
Exception Description: An exception was thrown while searching for persistence archives with ClassLoader: sun.misc.Launcher$AppClassLoader@6ce253f1
Internal Exception: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [insurance] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionSearchingForPersistenceResources(PersistenceUnitLoadingException.java:127)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:107)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:177)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
at org.simberg.configuration.EntityManagerConfigurator.getFactory(EntityManagerConfigurator.java:27)
at org.simberg.datastructures.entity.ReferenceData.getAll(ReferenceData.java:45)
at org.simberg.datastructures.entity.ReferenceData.init(ReferenceData.java:37)
at org.simberg.application.App.main(App.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [insurance] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1950)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1941)
at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.callPredeploy(JPAInitializer.java:98)
at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactoryImpl(PersistenceProvider.java:96)
... 12 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [insurance] failed.
Internal Exception: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:230)
... 16 more
Caused by: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class org.simberg.datastructures.entity.PaymentGraph] uses a non-entity [class org.simberg.datastructures.entity.Contract] as target entity in the relationship attribute [field contract].
at org.eclipse.persistence.exceptions.ValidationException.nonEntityTargetInRelationship(ValidationException.java:1378)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.RelationshipAccessor.getReferenceDescriptor(RelationshipAccessor.java:568)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processForeignKeyRelationship(ObjectAccessor.java:659)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ObjectAccessor.processOwningMappingKeys(ObjectAccessor.java:733)
at org.eclipse.persistence.internal.jpa.metadata.accessors.mappings.ManyToOneAccessor.process(ManyToOneAccessor.java:123)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processOwningRelationshipAccessors(MetadataProject.java:1578)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage3(MetadataProject.java:1831)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:580)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:585)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1865)
... 14 more
6724 [main] INFO org.simberg.datastructures.entity.ReferenceData - Reference Data Loaded
6724 [main] INFO org.simberg.application.App - Insurance Project Started...