我需要一张商品地图,但我需要制作的商品' key'是短暂的,冬眠不能成为一个关键的'。我该怎么办?
@Entity
@AssociationOverrides({
@AssociationOverride(name = "rela.city",
joinColumns = @JoinColumn(name = "cityId")),
@AssociationOverride(name = "rela.person",
joinColumns = @JoinColumn(name = "id")),
@AssociationOverride(name = "rela.social",
joinColumns = @JoinColumn(name = "code")) })
public class Person implements java.io.Serializable {
@EmbeddedId
private RelationshipId rela = new RelationshipId();
@Transient
public String getCode(){
return rela.getSocial().geCode();
}
....
}
@Entity
public class City implements java.io.Serializable {
@OneToMany(fetch = FetchType.LAZY,
mappedBy = "rela.city", cascade = CascadeType.ALL)
@MapKey(name = "code")
Map<String, Person> People = new HashMap<>();
....
}
正如您所看到的,我希望将代码作为地图的关键,但由于代码是暂时的,因此无法正常运行。