
Untitled
By: a guest on
Jun 2nd, 2012 | syntax:
None | size: 1.40 KB | hits: 11 | expires: Never
Howto Persist a Map<Entity, Integer> with JPA?
@Entity
class PerformanceRating{
....
....
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "performance_rating_progress_reward", joinColumns = { @JoinColumn(name = "id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "amount", nullable = false, updatable = false) })
public Map<Progress, Integer> getRewardAmountByProgressMap() {
return this.rewardAmountByProgressMap;
}
Use of @OneToMany or @ManyToMany targeting an unmapped class: fwl.domain.model.PerformanceRating.rewardAmountByProgressMap[java.lang.Integer]
rating
============
id int(11) PK
progress
============
id int(11) PK
amount int(11)
progress_has_rating
============
progress_id int(11) PK
rating_id int(11) PK
@Entity @Table class Rating {
@Id long id;
@ManyToMany(targetEntity = Progress.class,
cascade = CascadeType.ALL,
fetch = FetchType.EAGER)
@JoinTable(name = "progress_has_rating",
joinColumns = {@JoinColumn(name = "rating_id",
referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "progress_id",
referencedColumnName = "id")})
Set<Progress> progresses;
}
@Entity class Progress {
@Id long id;
@Basic long amount;
}