0

我有一个带有两个 @manytomany 注释属性的实体。这里的问题是,其中一个属性是持久的,而另一个则不是。可能是什么问题呢。实体如下。

@Entity("payment")
 public class PaymentData implements Serializable
{
    private Long pk;

    private Collection<PaymentItemData> paymentItem;
    /**
     *  minorPaymentItem
     *
     */
    private Collection<MinorPayItemData> minorPaymentItem;

@LazyCollection(LazyCollectionOption.FALSE)
    @ManyToMany
    @JoinTable(name = "payitem_m_assig",
    joinColumns =
    @JoinColumn(name = "pay_item_id", nullable = false),
    inverseJoinColumns =
    @JoinColumn(name = "minor_pay_item_id", nullable = false))
    public Collection<MinorPayItemData> getMinorPaymentItem()
    {
        return minorPaymentItem;
    }

    /**
     * @param minorPaymentItem the minorPaymentItem to set
     */
    public void setMinorPaymentItem(final Collection<MinorPayItemData> value)
    {
        this.minorPaymentItem = value;
    }



 @LazyCollection(LazyCollectionOption.FALSE)
    @ManyToMany
    @JoinTable(name = "payitem_assigned",
    joinColumns =
    @JoinColumn(name = "pay_item_id", nullable = false),
    inverseJoinColumns =
    @JoinColumn(name = "new_pay_item_id", nullable = false))
    public Collection<PaymentItemData> getPaymentItem()
    {
        return paymentItem;
    }

    /**
     * Set the property paymentItem
     *
     * @param value -paymentItem
     *
     */
    public void setPaymentItem(final Collection<PaymentItemData> value)
    {
        this.paymentItem = value;
    }    

}

 @Entity("minor")
    public class MinorPayItemData implements Serializable
    {

    }

 @Entity("major")
    public class PaymentItemData extends MinorPayItemData
    {

    }

MinorPayItemData 和 PaymentItemData 保存在同一个数据库中。它们由鉴别器列分开。

仅保留 paymentItem 属性。我究竟做错了什么。

4

0 回答 0