gpt4 book ai didi

java - 在 Hibernate 注释中返回具有条件的 Map

转载 作者:太空宇宙 更新时间:2023-11-04 08:47:00 25 4
gpt4 key购买 nike

我有一个包含以下列的表格:

id, target (string), audience_group_id, rating (Integer), job_id

target列是以下值之一的字符串表示形式:预测、实际、更新

我想在 Job 类中添加方法:

Map<AudienceGroup, Integer( this it the rating)> getAudienceRatingPerPredictedPrograms() .

我被注释困住了。我怎样才能告诉它返回 map ,目标中的值是“预测的”?

最佳答案

I am stuck with the annotation. How can I tell it to return map that the value in target is "predicted"?

如果这是可行的(我对表格设计有一些疑问,这需要一些测试),我想你必须将Map注释(@org.hibernate.annotations.MapKey/MapKeyManyToMany)与Hibernate的filtering结合使用。过滤关联的功能。

我首先会尝试根据需要映射Map(在您的情况下可能使用MapKeyManyToMany)。完成 map 后,应用过滤器。

我从来没有测试过这个。

引用文献

关于java - 在 Hibernate 注释中返回具有条件的 Map<Key, Value>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4116997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com