本文介绍了如何重写休眠集合联接列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的抽象父亲:

@MappedSuperclass
public abstract class AbstractEntity implements Serializable {

    @OneToMany(fetch = FetchType.LAZY)
    @JoinColumn(name = "entity_no", referencedColumnName = "MY_COLUMN")
    private Set<CLASS_TYPE> list;
}

我所有的实体都有此设置,但是每个实体都有不同的referencedColumnName.

All my entities has this set, but each entity has different referencedColumnName.

是否有一种方法可以仅覆盖@JoinColumn注释?

Is there a way to override only the @JoinColumn annotation?

推荐答案

您可以使用 AssociationOverride 批注.在您的情况下,它看起来像这样:

You can use AssociationOverride annotation. In your case it would look like this:

@Entity
@AssociationOverrides({
   @AssociationOverride(name = "list",
      joinColumns = @JoinColumn(referencedColumnName = "COLUMN_NEW_NAME"))
})
public class ConcreteEntity extends AbstractEntity {

}

这篇关于如何重写休眠集合联接列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-02 17:57