我有以下实体:
@Entity
@Table(name = "ITEM_WEIGHTS", uniqueConstraints = {})
public class ItemWeight {
private ItemWeightId id;
@Column(name = "PERCENTAGE", unique = false, nullable = false, insertable = false, updatable = false, precision = 10, scale = 2)
private float percentage;
public ItemWeight() {
}
@EmbeddedId
@AttributeOverrides({ @AttributeOverride(name = "itemId", column = @Column(name = "ITEM_ID", unique = false, nullable = false, insertable = false, updatable = false, precision = 10, scale = 0)) })
public ItemWeightId getId() {
return id;
}
// Setter and Getters
}
@Entity
@Table(name = "STORE")
public class Item extends Store {
private List<ItemWeight> weights = new LinkedList<ItemWeight>();
public Item() {
}
@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER, mappedBy = "id.itemId")
public List<ItemWeight> getItemWeights() {
return weights;
}
public void setItemWeights(List<ItemWeight> weights) {
this.weights = weights;
}
}
我的“ITEM_WEIGHTS”表包含3个主键:哪个SKIN_ID就是其中之一。
我想制作映射,因此最终每个“Item”实体都将包含STORE之间关联的所有“ItemWeights”的列表.ITEM_ID = ITEM_WEIGHTS.ITEM_ID
我该怎么做?