Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java EmbeddeBleid应映射为insert=";假;更新=";假;_Java_Hibernate_Jpa_Polymorphism - Fatal编程技术网

Java EmbeddeBleid应映射为insert=";假;更新=";假;

Java EmbeddeBleid应映射为insert=";假;更新=";假;,java,hibernate,jpa,polymorphism,Java,Hibernate,Jpa,Polymorphism,我有以下实体:Match与embeddedableidMatchKey和多态实体organizationmatch Hibernate在映射实体:net.satago.web.entities.OrganizationMatch列:referenceKind(应使用insert=“false”update=“false”进行映射)时出现了重复列。 我不知道怎么回事,我能不能在@embeddedableid的部件上使用@DiscriminatorColumn注释,使它们不可插入或更新 如果要区分的

我有以下实体:
Match
与embeddedableid
MatchKey
和多态实体
organizationmatch

Hibernate在映射实体:net.satago.web.entities.OrganizationMatch列:referenceKind(应使用insert=“false”update=“false”进行映射)时出现了
重复列。

我不知道怎么回事,我能不能在
@embeddedableid
的部件上使用
@DiscriminatorColumn
注释,使它们不可插入或更新

如果要区分的列不是
@embeddedableid
的一部分,而只是
匹配
实体上的一个常规列,则可以使用它

@Embeddable
@ParametersAreNonnullByDefault
public class MatchKey implements Serializable
{
    private static final long serialVersionUID = 7619427612022530146L;

    @Column(insertable = false, updatable = false)
    @Enumerated(STRING)
    private MatchableEntityKind referenceKind;

    private Long referenceId;

    public MatchKey()
    {
        // For JPA
    }

    public MatchKey(OrganisationId organisationId)
    {
        this.referenceKind = ORGANISATION;
        this.referenceId = organisationId.getId();
    }

    public MatchableEntityKind getReferenceKind()
    {
        return referenceKind;
    }

    public void setReferenceKind(MatchableEntityKind referenceKind)
    {
        this.referenceKind = referenceKind;
    }

    public Long getReferenceId()
    {
        return referenceId;
    }

    public void setReferenceId(Long referenceId)
    {
        this.referenceId = referenceId;
    }

    @Override
    public boolean equals(Object obj)
    {
        if (obj instanceof MatchKey)
        {
            MatchKey that = (MatchKey) obj;

            return this.referenceKind == that.referenceKind &&
                    Objects.equals(this.referenceId, that.referenceId);
        }

        return false;
    }

    @Override
    public int hashCode()
    {
        return Objects.hash(referenceKind, referenceId);
    }
}

@Entity
@Table(name = TABLE_NAME)
@Inheritance(strategy = SINGLE_TABLE)
@DiscriminatorColumn(name = "reference_kind", discriminatorType = DiscriminatorType.STRING)
@ParametersAreNonnullByDefault
public class Match implements EntityModel<MatchKey>
{
    static final String TABLE_NAME = "matches";

    @EmbeddedId
    private MatchKey id;

    @Version
    private Long version;

    ... generic match columns
}
@Entity
@DiscriminatorValue(OrganisationMatch.REFERENCE_KIND)
@ParametersAreNonnullByDefault
public class OrganisationMatch extends Match
{
    static final String REFERENCE_KIND = "ORGANISATION";

    @JoinColumn(name = "reference_id")
    @OneToOne(fetch = LAZY, optional = false)
    private Organisation organisation;

    public OrganisationMatch()
    {
        setReferenceKind(MatchableEntityKind.valueOf(REFERENCE_KIND));
    }

    public OrganisationMatch(OrganisationId organisationId)
    {
        super(new MatchKey(organisationId));
        setReferenceKind(MatchableEntityKind.valueOf(REFERENCE_KIND));
    }

    public Organisation getOrganisation()
    {
        return organisation;
    }
}