0

我正在为所有客户构建一个具有共同实体基础的 Web 应用程序

现在有些客户需要额外的字段,但我不想全部添加。我想过这样的事情:

@Embeddable
public class AdditionalDetails {

private String label;

private String text;

public AdditionalDetails() {}


    // autogenerated getters and setters, hashCode(), equals()
} 
    
@Entity
public class BusinessObject {

    @Id
    @Column(name = "string_id")
    private long id;

    @ElementCollection(fetch=FetchType.EAGER)
    @MapKey(name = "language")
    @CollectionTable(schema = "label", name = "multilingual_string_map", 
              joinColumns = @JoinColumn(name = "string_id"))
    private Map<String, AdditionalDetails> map = new HashMap<String, AdditionalDetails>();

    public BusinessObject() {}

    // autogenerated getters and setters, hashCode(), equals()
}

不,问题是我将配置由 BusinessObject 添加到哪些属性?

4

1 回答 1

1

您可以@Entity从基类中删除注释。然后从您的基类创建子类并将@Entity注释添加到子类。现在您可以避免将所有属性放在基类中,而是可以将它们添加到适当的子类中。

于 2013-09-22T16:08:07.857 回答