休眠ManyToMany和SINGLE_TABLE继承吗?

时间:2018-08-07 08:12:23

标签: java hibernate jpa

请告诉我我做错了什么?

我想在一张表中设置ManyToMany关系比率。这可能吗?

library(DescTools)
Gini(income.df$income, n = rep(1, length(income.df$income)), unbiased = TRUE, conf.level = NA, R = 1000, type = "bca", na.rm = TRUE)

K实体

@Entity
@Table(name = "external_offer")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "offer_type", discriminatorType = DiscriminatorType.STRING)
public abstract class ExternalOffer

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    ......

EOffer-实体

@Entity
@Table(name = "k")
public class K
{
    @Id
    @Column(name = "id", nullable = false, updatable = false)
    private long id;

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(
        name = "K2GlobalOffer",
        joinColumns = @JoinColumn(
            name = "k_id", referencedColumnName = "id"),
        inverseJoinColumns = @JoinColumn(
            name = "global_offer_id", referencedColumnName = "id"))
    private List<GlobalExternalOffer> globalExternalOffers;

我在这里收到错误消息。不明白为什么。仅当存在ManyToMany时,我会收到此错误。 OneToMany关系-正常工作。

@Entity
@DiscriminatorValue("GLOBAL")
public class GlobalExternalOffer extends ExternalOffer
{

    @ManyToMany(mappedBy = "globalExternalOffers", fetch = FetchType.EAGER)
    private List<K> kRef;

感谢您的帮助。

0 个答案:

没有答案