I have a table with the following columns:
id, target (string), audience_group_id, rating (Integer), job_id
target column is a string representation of one of the following values:
predicted, actual, updated
I thought to add method in Job class:
Map<AudienceGroup, Integer( this it the rating)> getAudienceRatingPerPredictedPrograms().
I am stuck with the annotation. How can I tell it to return map that the value in target is “predicted”?
If this is doable (I have some doubts about the table design, this will require some testing), I think you’ll have to use the
Mapannotations (@org.hibernate.annotations.MapKey/MapKeyManyToMany) in conjunction with Hibernate’s filtering capabilities to filter the association.I would first try to map the
Mapas wanted (probably usingMapKeyManyToManyin your case). Once done with theMap, apply the filter.I’ve never tested this.
References