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

后端 未结 7 1738
北恋
北恋 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:28

    What you are asking is not supported out of the box by hibernate. See http://opensource.atlassian.com/projects/hibernate/browse/HHH-869

    Here is a workaround available in the jira ticket :

    entityCriteria.add(Restrictions.sqlRestriction(
      "fooAlias.id in (select e.id from foobar_table e, values_table v" + 
      " where e.id = v.entity_id and v.field = ?)", "abc123"), Hibernate.String)) ;
    
    0 讨论(0)
提交回复
热议问题