gpt4 book ai didi

java - 异常描述: xxx uses a non-entity xx as target entity in the relationship attribute [method xxx]

转载 作者:行者123 更新时间:2023-11-30 05:21:14 35 4
gpt4 key购买 nike

我在将 java ee 应用程序部署到 weblogic 服务器 12.x 时遇到此错误:

[11:50:07 AM] [Deployer:149034]An exception occurred for task [Deployer:149026]deploy application habib on AdminServer.: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class net.tbse.back.inventory.salesRep.entities.SalesRepCommision] uses a non-entity [class net.tbse.back.inventory.salesRep.entities.Commission] as target entity in the relationship attribute [method getCommission]..
[11:50:07 AM] weblogic.application.ModuleException: Exception [EclipseLink-7250] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: [class net.tbse.back.inventory.salesRep.entities.SalesRepCommision] uses a non-entity [class net.tbse.back.inventory.salesRep.entities.Commission] as target entity in the relationship attribute [method getCommission].

我的佣金类代码是:

package net.tbse.back.inventory.salesRep.entities;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import javax.persistence.Transient;

import net.tbse.back.accounting.chartOfaccount.tree.entiteis.Account;
import net.tbse.back.inventory.salesYeas.entities.SalesYear;


@Entity
@Table(name = "COMMISSIONS")
public class Commission implements Serializable {

private Long commissionsId;
private Long companyId;
private Double fromAmount;
private Double toAmount;
private Long percentage;
private SalesYear salesYear;
private Account commissionAccount;
private String commissionAccountName;



public Commission() {
super();
}

@TableGenerator(name = "CommissionGen", table = "SEQUENCE",
pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "COMMISSIONS")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "CommissionGen")
@Id
@Column(name = "COMMISSION_ID", nullable = false)
public Long getCommissionsId() {
return commissionsId;
}

public void setCommissionsId(Long commissionsId) {
this.commissionsId = commissionsId;
}

public void setFromAmount(Double fromAmount) {
this.fromAmount = fromAmount;
}

@Column(name = "FROM_AMOUNT")
public Double getFromAmount() {
return fromAmount;
}

public void setToAmount(Double toAmount) {
this.toAmount = toAmount;
}

@Column(name = "TO_AMOUNT")
public Double getToAmount() {
return toAmount;
}

public void setPercentage(Long percentage) {
this.percentage = percentage;
}

@Column(name = "DEF_PERCENTAGE")
public Long getPercentage() {
return percentage;
}

public void setCompanyId(Long companyId) {
this.companyId = companyId;
}
@Column(name = "COMPANY_ID")
public Long getCompanyId() {
return companyId;
}

public void setSalesYear(SalesYear salesYear) {
this.salesYear = salesYear;
}

@ManyToOne
@JoinColumn(name = "SALES_YEAR_ID")
public SalesYear getSalesYear() {
return salesYear;
}

public void setCommissionAccount(Account commissionAccount) {
this.commissionAccount = commissionAccount;
}

@ManyToOne
@JoinColumn(name="COMMISSION_ACCOUNT_ID")
public Account getCommissionAccount() {
return commissionAccount;
}

public void setCommissionAccountName(String commissionAccountName) {
this.commissionAccountName = commissionAccountName;
}

@Transient
public String getCommissionAccountName() {

if (isNullOrEmpty(commissionAccountName)) {

if (getCommissionAccount() != null) {

commissionAccountName = getCommissionAccount().getName();

}
}

return commissionAccountName;
}

@Transient
public boolean isNullOrEmpty(String s) {
return (s == null) || s.trim().equals("");
}
}

这是 SalesRepCommission 类代码:

package net.tbse.back.inventory.salesRep.entities;

import java.io.Serializable;

import java.util.HashMap;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

import javax.persistence.Transient;

import net.tbse.back.inventory.salesYeas.entities.SalesPeriod;
import net.tbse.back.inventory.salesYeas.entities.Target;


@Entity
@Table(name = "SALES_REP_COMMISSIONS")
public class SalesRepCommision implements Serializable {

private Long salesRepCommissionsId;
private SalesRep saleRep;
private Commission commission;
private Map<Long,Target> salesPeriodCommissions = new HashMap<Long, Target>();
private Double fromAmount;
private Double toAmount;



public void setSalesRepCommissionsId(Long salesRepCommissionsId) {
this.salesRepCommissionsId = salesRepCommissionsId;
}

@TableGenerator(name = "SalesRepCommisionsGenerator", table = "SEQUENCE",
pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT",
pkColumnValue = "SALES_REP_COMMISSIONS")
@GeneratedValue(strategy = GenerationType.TABLE, generator = "SalesRepCommisionsGenerator")
@Id
@Column(name = "SALES_REP_COMMISSIONS_ID", nullable = false)
public Long getSalesRepCommissionsId() {
return salesRepCommissionsId;
}


public void setSaleRep(SalesRep saleRep) {
this.saleRep = saleRep;
}

@ManyToOne
@JoinColumn(name = "SALES_REP_ID")
public SalesRep getSaleRep() {
return saleRep;
}


public void setCommission(Commission commission) {
this.commission = commission;
}

@OneToOne
@JoinColumn(name = "COMMISSION_ID")
public Commission getCommission() {
return commission;
}

public void setSalesPeriodCommissions(Map<Long, Target> salesPeriodCommissions) {
this.salesPeriodCommissions = salesPeriodCommissions;
}

@Transient
public Map<Long, Target> getSalesPeriodCommissions() {
return salesPeriodCommissions;
}

public void setToAmount(Double toAmount) {
this.toAmount = toAmount;
}

@Column(name = "TO_AMOUNT")
public Double getToAmount() {
return toAmount;
}

public void setFromAmount(Double fromAmount) {
this.fromAmount = fromAmount;
}
@Column(name = "FROM_AMOUNT")
public Double getFromAmount() {
return fromAmount;
}
}

这是 persistance.xml 文件:

persistance.xml

此外,我还检查了 persistence.xml 并且该类已正确包含在同一包中。编译过程成功完成并生成了一个jar文件。

有人可以帮我解决这个问题吗?这里肯定有错误,但我找不到它。

最佳答案

我认为类Commission未声明为@Entity。显示其代码。

关于java - 异常描述: xxx uses a non-entity xx as target entity in the relationship attribute [method xxx],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59542685/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com