简体   繁体   中英

How to test SQL dynamic queries?

My applications are Spring/iBatis (2.3) based. I usually write a lot of dynamic queries in my sqlMaps and I'd like to test my generated SQL queries to avoid any syntax errors. For more precision, I want to:

  1. check the SQL syntax (depending on the sql dialect) of all my generated queries
  2. check if my queries work correctly with the actual database structure

Does already exist a library that gives me the chance to check the SQL syntax (step 1), depending on the sql dialect (I'm actually using Oracle), without a database connection?

Does already exist a sqlMap parser which could help me generating all potential queries, containing all combinations of dynamic parameters?

Basically, I'm thinking about a way to avoid writing one (or more) unit test per query. I'd like to automate this step to be sure that my generated queries are always right. Any other suggestions?

There is a related question and some people suggested using DBUnit . Maybe you should give it a try.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM