Search code examples
javasqlibatis

Is iBatis the right choice for dynamic SQL queries?


I'm facing the following design issue:

  • There will be several prepared SQL statements where the WHERE-clause contains defined contraints in which the values will be dynamic, based on user input.
  • In addition there will be some SQL statements required that might end up to be pretty complex, but the resulting SELECT-clause) will still be pretty straight-forward.

As far as I understand iBatis would fit into these requirements.

  • Now what happens in a scenario where the user (through a UI) would influence the complete query construction, making the queries on an adhoc basis?

A prepared statement can't do it as the whole WHERE clause is dynamic, we might even have aggregation clauses or even sub-selects built into the SQL functions.

With all of this in mind, would you still go with iBatis or do some other custom development as the best architecture given the above requirements?


Solution

  • Latest version of iBatis (MyBatis) is allowing us to use powerful OGNL based expressions for constructing dynamic queries. One of the most powerful features of iBATIS has always been its Dynamic SQL capabilities.