动态查询与休眠 [英] Dynamic queries with hibernate

查看:179
本文介绍了动态查询与休眠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,我需要通过某种类型的向导来定义他们的选项,以便让最终用户创建即席报告,其过程类似于:

<$ p $用户选择他想要查询的表格(例如,人员,项目,活动)
2)定义他需要的字段列表(例如姓名,电子邮件,项目,活动,活动信息)
3)为返回的记录提供过滤标准(例如人名,正在进行的活动)

我使用hibernate和超过100个表的postgres数据库。当然,我不能让用户选择任何表格,因为他们没有意义。但是大约有10个主表(比如上面的表)。

所以我需要关于如何操作的建议:


  1. 是否有可能以及如何动态定义这些表与其他关系之间的联接和关系?如果不是(或者太复杂),那么预定义这些连接和数据库路径的最好方法是什么,然后让用户只参数化过滤器?

  2. 从多个hibernate对象获取数据,然后让用户选择他想要的字段。

我非常欣赏所有的反馈,如果我没有正确解释需要,请写信。

解决方案

http://docs.jboss.org/hibernate/core/3.6/reference/zh-CN/html_single/# querycriteria


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).

So I need advice on how to:

  1. Is it possible and how to define joins and relations between these tables and their other relations dynamically?
  2. 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?
  3. 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.

解决方案

http://docs.jboss.org/hibernate/core/3.6/reference/en-US/html_single/#querycriteria

这篇关于动态查询与休眠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆