当前位置: 首页 > 知识库问答 >
问题:

JPA javax.persistence.metamodel.ListAttribute

薛元忠
2023-03-14

我正在运行一个JPA测试,我在这篇文章的末尾不断得到错误。我不知道为什么我会得到这个错误,但是,我在JUnit测试时没有得到这个错误。我知道这可能是一个一般性的信息和一个广泛的问题,但如果有一个简单的答案,我将不胜感激。

以下是我的3个类文件:

package menu.entity;

import static javax.persistence.CascadeType.ALL;

import java.io.Serializable;
import javax.persistence.*;

import java.math.BigDecimal;
import java.util.List;

@IdClass(menu.entity.FeatureKey.class)
@Entity
@Table(name="FEATURES")
public class Feature implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@Column(name="PROD_ID", 
        nullable = false, 
        insertable = false, 
        updatable = false,
        precision=22)
private BigDecimal prodId;

@Id
@Column(name="FEATURE", 
        nullable = false, 
        insertable = false, 
        updatable = false,
        precision=22)
private BigDecimal feature;

@Column(name="FEATURE_NAME", length=50)
private String featureName;

@Column(name="FEATURE_PATH", length=100)
private String featurePath;

@OneToMany(cascade=ALL, mappedBy="featureObj")
private List<Function> functions;

@ManyToOne
@JoinColumns({
    @JoinColumn(name="PROD_ID", referencedColumnName="PROD_ID")
    })
private Product product;

public Feature() {
}

public BigDecimal getFeature() {
    return this.feature;
}

public void setFeature(BigDecimal feature) {
    this.feature = feature;
}

public String getFeatureName() {
    return this.featureName;
}

public void setFeatureName(String featureName) {
    this.featureName = featureName;
}

public String getFeaturePath() {
    return this.featurePath;
}

public void setFeaturePath(String featurePath) {
    this.featurePath = featurePath;
}

public BigDecimal getProdId() {
    return this.prodId;
}

public void setProdId(BigDecimal prodId) {
    this.prodId = prodId;
}

public Product getProduct() {
    return product;
}

public void setProduct(Product product) {
    this.product = product;
}

public List<Function> getFunctions() {
    return functions;
}

public void setFunctions(List<Function> functions) {
    this.functions = functions;
}

}


package menu.entity;

import java.math.BigDecimal;
import javax.annotation.Generated;
import javax.persistence.metamodel.ListAttribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;

@Generated(value="Dali", date="2012-10-01T17:03:26.750-0400")
@StaticMetamodel(Feature.class)
public class Feature_ {
public static volatile SingularAttribute<Feature, BigDecimal> prodId;
public static volatile SingularAttribute<Feature, BigDecimal> feature;
public static volatile SingularAttribute<Feature, String> featureName;
public static volatile SingularAttribute<Feature, String> featurePath;
public static volatile ListAttribute<Feature, Function> functions;
public static volatile SingularAttribute<Feature, Product> product;
}


package menu.entity;

import static javax.persistence.CascadeType.ALL;

import java.io.Serializable;
import javax.persistence.*;

import java.math.BigDecimal;
import java.util.List;


@IdClass(menu.entity.FunctionKey.class)
@Entity
@Table(name="FUNCTIONS")
public class Function implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@Column(name="PROD_ID", 
        nullable = false, 
        insertable = false, 
        updatable = false,
        precision=22)
private BigDecimal prodId;

@Id
@Column(name="FEATURE", 
        nullable = false, 
        insertable = false, 
        updatable = false,
        precision=22)
private BigDecimal feature;

@Id
@Column(name="FUNC", 
        nullable = false, 
        insertable = false, 
        updatable = false,
        precision=22)
private BigDecimal func;

@Column(name="FUNC_NAME", length=50)
private String funcName;

@Column(name="FUNC_PATH", length=80)
private String funcPath;

@OneToMany(cascade=ALL, mappedBy="function")
private List<Task> tasks;

@ManyToOne
@JoinColumns({
    @JoinColumn(name="PROD_ID", referencedColumnName="PROD_ID"),
    @JoinColumn(name="FEATURE", referencedColumnName="FEATURE")
    })
private Feature featureObj;

public Function() {
}

public BigDecimal getFeature() {
    return this.feature;
}

public void setFeature(BigDecimal feature) {
    this.feature = feature;
}

public BigDecimal getFunc() {
    return func;
}

public void setFunc(BigDecimal func) {
    this.func = func;
}

public String getFuncName() {
    return this.funcName;
}

public void setFuncName(String funcName) {
    this.funcName = funcName;
}

public String getFuncPath() {
    return this.funcPath;
}

public void setFuncPath(String funcPath) {
    this.funcPath = funcPath;
}

public BigDecimal getProdId() {
    return this.prodId;
}

public void setProdId(BigDecimal prodId) {
    this.prodId = prodId;
}

public Feature getFeatureObj() {
    return featureObj;
}

public void setFeatureObj(Feature featureObj) {
    this.featureObj = featureObj;
}

public List<Task> getTasks() {
    return tasks;
}

public void setTasks(List<Task> tasks) {
    this.tasks = tasks;
}

}

以下是完整的堆栈跟踪:

共有1个答案

农诚
2023-03-14

我认为引发RuntimeException是因为发生了另一个异常。另一个异常的堆栈跟踪应该打印到控制台。

 类似资料:

相关问答

相关文章

相关阅读