Designing complex query builders in java/jpa/hibernate
Posted
by
Ramraj Edagutti
on Programmers
See other posts from Programmers
or by Ramraj Edagutti
Published on 2012-04-14T04:21:48Z
Indexed on
2012/04/14
11:44 UTC
Read the original article
Hit count: 319
I need to build complex sql queries programatically, based on large filter conditions.
For example, below are few sample/hypothitical filter conditions, based on which i need to fetch users
Country: india
States: Andhra Pradesh(AP), Gujarat(GUJ), karnataka(KTK)
Districts: All districts in AP except 3 district, 5 any districts from GUJ, all district from KTK except 1 district
Cities: All cities in AP, all cities except few, include only 50 specific cities from KTK
Villages: similar conditions like above with varies combinations...
Currently, we have a query builder, which is very complex in nature, and not easy to modify/re-factory for improvements. So, thinking of complete re-design of it.
Any suggesations on how to build this kind of complex query builders programmatically using some best practices/deisgn patterns?
© Programmers or respective owner