Mix HQL and Criteria API in Hibernate

2020-04-21 05:15发布

Is it possible to mix HQL and the Criteria API?

I have a String that contains a where condition in HQL and a Criteria that is already built and got from somewhere else. I wonder if I can add the where condition String to Criteria.add(). The where condition could be multiple conditions "and-ed"/"or-ed" together.

Can I do this without parsing the where condition String?

2条回答
够拽才男人
2楼-- · 2020-04-21 05:40

have a look at Filters

查看更多
小情绪 Triste *
3楼-- · 2020-04-21 05:45

You can use Restriction.sqlRestriction(String sql).

查看更多
登录 后发表回答