0
@Entity
@Table(name="Product_info")

public class Product {
    private int ProductIndex;
    private int priority;
    private Date dateTime;
    private String action;
    private String status;

    @ManyToOne
    @JoinColumn(name="releaseIndex")
    private Release release;

    @Id
    @GeneratedValue
    @Column(name="id")
    protected int getProductIndex() {
        return ProductIndex;
    }
    protected void setProductIndex(int ProductIndex) {
        this.ProductIndex = ProductIndex;
    }
    public Release getRelease() {
        return release;
    }
    public void setRelease(Release release) {
        this.release = release;
    }
    /*public Region getRegion() {
        return region;
    }
    public void setRegion(Region region) {
        this.region = region;
    }*/
    @Column(name="priority")
    public int getPriority() {
        return priority;
    }
    public void setPriority(int priority) {
        this.priority = priority;
    }
    @Column(name="datetime")
    public Date getDateTime() {
        return dateTime;
    }
    public void setDateTime(Date dateTime) {
        this.dateTime = dateTime;
    }
    @Column(name="action")
    public String getAction() {
        return action;
    }
    public void setAction(String action) {
        this.action = action;
    }
    @Column(name="status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }

    public Product() {
    }

    public Product(int priority, Date dateTime, String action, String status) {
        this.priority = priority;
        this.dateTime = dateTime;
        this.action = action;
        this.status = status;
    }
}


@Entity
@Table(name="release")


public class Release {
    private int releaseIndex;
    private String releaseName;
    private Set<ProductInfo> productInfo = new HashSet<ProductInfo>();

    @Id
    @GeneratedValue
    @Column(name="id")
    protected int getReleaseIndex() {
        return releaseIndex;
    }
    protected void setReleaseIndex(int releaseIndex) {
        this.releaseIndex = releaseIndex;
    }
    @Column(name="name")
    public String getReleaseName() {
        return releaseName;
    }
    public void setReleaseName(String releaseName) {
        this.releaseName = releaseName;
    }
    @OneToMany(mappedBy="release")
    public Set<ProductInfo> getProductInfo() {
        return ProductInfo;
    }
    public void setProductInfo(Set<ProductInfo> productInfo) {
        this.productInfo = productInfo;
    }
}

以上是我想创建 ManytoOne 关系的两个类,但它给了我错误无法确定类型:dao.Release,在表:product_info,对于列:[org.hibernate.mapping.Column(release)]

4

1 回答 1

0

您会遇到此错误,因为注释有时在字段中有时在方法中不一致。如果您不想使用 AccessType,最简单的解决方案是将注释从 release-field 移动到 getRelease 方法。

于 2012-06-18T12:48:12.467 回答