熟悉Hibernate的查询生成 [英] Hooking into Hibernate's query generation
本文介绍了熟悉Hibernate的查询生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用预处理器实现虚拟视图.一个简单的例子:
I would like to implement virtual views with a preprocessor. A simple example:
之前的HQL:
FROM PublishedArticle a
之后的有效HQL
FROM Article a
WHERE a.published = true
从本质上讲,我需要一种在查询执行之前对其进行处理的方法(而不是动态创建视图,这会带来很高的成本).
Essentially I need a way to process queries before they get executed (instead of creating views on-the-fly which would have a high cost).
推荐答案
您可以使用StatementInspector
完全重写SQL以适合您的需求.
You can use a StatementInspector
to completely rewrite the SQL to suit your needs.
进一步阅读:如何在Hibernate中配置StatementInspector?
这篇关于熟悉Hibernate的查询生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文