返回MapHibernate 注释中的 with 条件
我有一个包含以下列的表:
id, target (string), audience_group_id, rating (Integer), job_id
target
列是以下值之一的字符串表示形式: 预测、实际、更新
我想在 Job 类中添加方法:
Map
。
我被注释困住了。我怎样才能告诉它返回映射目标中的值是“预测的”?
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"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这是可行的(我对表格设计有一些疑问,这需要一些测试),我认为你必须使用
Map
注释(@org.hibernate.annotations.MapKey/MapKeyManyToMany
) 与 Hibernate 的 过滤 功能来过滤关联。我首先尝试根据需要映射
Map
(在您的情况下可能使用MapKeyManyToMany
)。完成Map
后,应用过滤器。我从来没有测试过这个。
参考资料
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
Map
annotations (@org.hibernate.annotations.MapKey/MapKeyManyToMany
) in conjunction with Hibernate's filtering capabilities to filter the association.I would first try to map the
Map
as wanted (probably usingMapKeyManyToMany
in your case). Once done with theMap
, apply the filter.I've never tested this.
References