Hibernate Criteria API - adding a criterion: string should be in collection

后端 未结 7 1740
北恋
北恋 2020-12-16 06:05

I have to following entity object


@Entity
public class Foobar {
    ...
    private List uuids;
    ...
}

Now I\'d like to

7条回答
  •  眼角桃花
    2020-12-16 06:27

    I know this is old question, but I have just encountered this issue and found solution.

    If you want to use Hibernate Criteria you can join your uuids collection and use its property elements to match elements. Just like that:

    session.createCriteria(Foobar.class)
        .createAlias("uuids", "uuids")
        .add(Restrictions.eq("uuids.elements", "MyUUID"))
        .list() 
    

提交回复
热议问题