在Hibernate中混合使用HQL和Criteria API [英] Mix HQL and Criteria API in Hibernate
本文介绍了在Hibernate中混合使用HQL和Criteria API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以混合使用HQL和Criteria API吗?
我有一个字符串
,它包含一个where HQL中的条件和已经构建并从其他地方获得的 Criteria
。我想知道是否可以将where条件 String 添加到
Criteria.add()
。
我可以在不解析where条件的情况下执行此操作吗?字符串
?
解决方案
您可以使用 Restriction.sqlRestriction (String sql)。
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
?
解决方案
You can use Restriction.sqlRestriction(String sql).
这篇关于在Hibernate中混合使用HQL和Criteria API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文