首页 > 代码库 > spring data jpa 关联设计

spring data jpa 关联设计

MAP关联实体

//    @ElementCollection
@OneToMany(cascade = {CascadeType.ALL})
// @JoinColumn(name = "theme_id")
// @MapKeyEnumerated(EnumType.STRING)
@MapKeyColumn(name="selector")
// @Column(name="block_style_id")
// @JoinColumn(name = "block_style_id")
// @CollectionTable(name="theme_block_style", joinColumns=@JoinColumn(name="my_id"))
// @CollectionTable(name="theme_style")
@JoinTable(name = "theme_style")
private Map<String, BlockStyle> style = new HashMap<>();

MAP关联组件:
    @ElementCollection
// @OneToMany(cascade = {CascadeType.ALL})
// @JoinColumn(name = "theme_id")
// @MapKeyEnumerated(EnumType.STRING)
@MapKeyColumn(name="selector")
// @Column(name="block_style_id")
// @JoinColumn(name = "block_style_id")
// @CollectionTable(name="theme_block_style", joinColumns=@JoinColumn(name="my_id"))
@CollectionTable(name="theme_style")
// @JoinTable(name = "theme_style")
private Map<String, BlockStyle> style = new HashMap<>();

spring data jpa 关联设计