简体   繁体   English

在Hibernate中混合使用HQL和Criteria API

[英]Mix HQL and Criteria API in Hibernate

Is it possible to mix HQL and the Criteria API? 是否可以将HQL和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. 我有一个String ,其中包含HQL WHERE条件和Criteria是已建成,并从其他地方得到。 I wonder if I can add the where condition String to Criteria.add() . 我想知道是否可以将条件条件String添加到Criteria.add() The where condition could be multiple conditions "and-ed"/"or-ed" together. where条件可以是多个条件“与-或-” /“或-或”在一起。

Can I do this without parsing the where condition String ? 我可以在不解析where条件String情况下执行此操作吗?

您可以使用Restriction.sqlRestriction (字符串sql)。

看看过滤器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM