通过其键在ElementCollection Map中进行休眠限制

时间:2019-05-04 19:56:15

标签: hibernate jpa criteria

我的Entities如下...

@Entity
@Table(name = "PROJECT")
public class CProject implements Serializable {
    @Id
    private Long id;

    @OneToOne(fetch = FetchType.LAZY)
    @Fetch(FetchMode.SELECT)
    @JoinColumn(name = "TEAM")
    private Team team;

}

还有

@Entity
@Table(name = "TEAM")
public class Team implements Serializable {
    @Id
    private Long id;

    private Date formedDate;

    @ElementCollection(fetch = FetchType.EAGER)
    @MapKeyColumn(name = "MEM_ID")
    @Column(name = "WEIGHTAGE")
    @CollectionTable(name = "TEAM_MEMBERS")
    private Map<Long, Integer> teamMembers = new HashMap<>();

}

我还有一个名为Entity的{​​{1}}。与Member有关的某些成员。这些成员由Team

管理

我想通过他/他们的private Map<Long, Integer> teamMembers;获得Project参与团队成员的名单。目前我正在使用Long id

请注意:Map Key中使用的TeamMember ID,例如DetachedCriteria / Criteria

0 个答案:

没有答案