Dynamic queries with hibernate

我只是一个虾纸丫 提交于 2019-12-10 18:27:19

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/4773080/dynamic-queries-with-hibernate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!