//1.注解实体类型
@OneToMany(targetEntity = ProductBean.class, fetch = FetchType.EAGER)
@JoinTable(
name = "t_order_product_bean",//关联表的表名
joinColumns = {
@JoinColumn(name = "order_id")//关联表中约束于这个类的外键字段名字
},
inverseJoinColumns = {
@JoinColumn(name = "productBean_id")//关联表中约束于ProductBean的外键字段名字
}
)
public Set<ProductBean> getProductBeans() {
return productBeans;
}
//2.注解普通数据类型
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(
name = "t_shopping_mall_product_detail_images",//关联表的表名
joinColumns = {
@JoinColumn(name = "product_id")//关联表中约束于这个类的外键字段名字
}
)
public Set<String> getDetailImagesURL() {
return detailImagesURL;
}
转载于:https://my.oschina.net/u/2398421/blog/491480