Dynamic Query Generation (DQGen) Framework is a data-access framework specialized for reporting needs. The idea behind this framework is to view the underlying data source as logically related data sets. The framework exposes a criteria API to dynamically construct the SQL queries. The criteria API allows the user to create correlated queries (Doesn't expect the from clause to be specified by the user. Makes use of the predefined logical relationships) and un-correlated queries (Traditional query where the user has to specify the from clause)
The framework expects the user to identify all the roles a relational table maintain. For instance, the USER table in a cart application can have two roles BUYER & SELLER and the same table in an organization could have the roles EMPLOYEE, MANAGER & HR_MANAGER. Once the roles are identified, the user has to define logical relationship between them. The framework then creates meta models for the logical data sets which can be used in conjunction with the criteria API to generate the queries.
The framework provides tools to generate the logical relationships and the meta model classes. The figure below shows the high level work flow,
If the roles and relationships are predefined, queries can be dynamically created without a need to specify the from clause and join clauses. If the relationships are not defined, still queries can be dynamically created by specifying the from and join clauses
There could be cases where one might want to join the tables with predefined relationships and those without any relationships defined. The framework allows us to join correlated and correlated queries as well
The relationships between the roles defined by you leads to a cyclic graph, the framework still would find the optimized path (under development) and create the query for you
Transform enums and status flags to display strings o Look up based on custom maps
Generates meta-model classes for the database table instances to drive the query generation. So no hard coding of database meta-data information
Provides tools to create the mapping files from the database meta data and generate the meta model classes