0

我有以下实体:

@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 是其中之一。

我想进行映射,所以最终每个“项目”实体都将包含一个在 STORE.ITEM_ID = ITEM_WEIGHTS.ITEM_ID 之间关联的所有“ItemWeights”的列表

我怎样才能做到这一点??

4

0 回答 0