java 使用休眠的动态查询
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4773080/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Dynamic queries with hibernate
提问by Julia
I have an application where i need to enable end users to create adhoc reports by defining their options through some type of wizard whose process would be something like:
我有一个应用程序,我需要让最终用户通过某种类型的向导定义他们的选项来创建临时报告,其过程类似于:
1) User selects the table(s) he wants to query (eg person, project, activities)
2) defines the list of fields he requires (eg name, email, projects, activity, activity info)
3) supplies the filter criteria for the records to return (eg Person name, ongoing activities)
I am using hibernate with postgres database with more than 100 tables. Sure, I can not let the user pick any of those tables since they make no sense. But some 10 main tables (such as ones from above).
我正在使用带有 100 多个表的 postgres 数据库的休眠。当然,我不能让用户选择这些表中的任何一个,因为它们毫无意义。但是大约有 10 个主表(例如上面的表)。
So I need advice on how to:
所以我需要关于如何的建议:
- Is it possible and how to define joins and relations between these tables and their other relations dynamically?
- If not, (or too complex), what would be the best way to predefine these joins and database paths, and then let user only parametrize filters?
- Obtain data from more than one hibernate object and then let the user chooses fields he wants.
- 是否可以以及如何动态定义这些表与其其他关系之间的连接和关系?
- 如果不是,(或太复杂),预定义这些连接和数据库路径的最佳方法是什么,然后让用户只对过滤器进行参数化?
- 从多个休眠对象中获取数据,然后让用户选择他想要的字段。
I appreciate much all the feedback, if i did not explain the need properly please write.
我非常感谢所有的反馈,如果我没有正确解释需求,请写信。