5

Consider the following entity.

@Entity
public class Member {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private String memberName;

    @ElementCollection
    @CollectionTable(joinColumns=@JoinColumn(name="memberId"))
    @MapKeyColumn(name="prop")
    @Column(name="val")
    private Map<String, Boolean> checklist;

    /** usual getters and setters **/
}

Assuming the above entity creates two table; member and member_checklist; is it possible for me to achieve the following sql statement with jpa 2 criteria api?

select * from member where id not in (
    select memberid from member_checklist where prop in (2));

I've read Hibernate Criteria API - adding a criterion: string should be in collection but I still can't figure out how I can achieve my goal.

Looking forward to some expert opinions.

Community
  • 1
  • 1
Qcumber
  • 130
  • 1
  • 2
  • 14
  • It is possible with JPA 2 Criteria-api, but because of Hibernate bug explained here http://stackoverflow.com/questions/5580614/jpa-criteriabuilder-join-maps it does not work as long as you use Hibernate – Mikko Maunu Sep 22 '11 at 13:51
  • @MikkoMaunu If I don't use hibernate, can you tell me how I can achieve the above with criteria-api? – Qcumber Sep 22 '11 at 18:36

0 Answers0