ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nils Winkler" <n...@nilswinkler.com>
Subject Re: checking that a statement exists
Date Thu, 10 Aug 2006 06:34:06 GMT
Hi,

why do you want to check this at runtime? It's too late by then
anyway...

Here's what we're doing: For every DAO method, we create a unit test
using JUnit, the test cases are executed as part of our build process.
We use a code coverage tool to make sure that everything is called at
least once during testing. This way we make sure that a) the statements
actually exist, b) the SQL and mappings do in fact work against the
current data model in the DB and c) minimize the risk of runtime errors.

Hope that helps,

Nils

On Wed, 9 Aug 2006 08:38:51 -0700, "Reuben Firmin"
<Reuben.Firmin@Copart.Com> said:
> Hello, is there any way to ask the SqlMapClient object whether a given
> statement exists?
>  
> I am thinking of a pattern like this:
>  
> enum StatementName
> {
>       GET_FOO("getFoo");
>       GET_BAH("getBah");
> }
>  
> ...
>  
> sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
> for (StatementName statement: StatementName.values())
> {
>      if (!sqlMap.statementExists(statement))
>      {
>          throw ProgrammerErrorException(....)
>      }
> }
>  
> ...
>  
> sqlMap.queryForList(StatementName.GET_FOO, ...)
>  
> Thanks
> Reuben
--
==================================
nils@nilswinkler.com


Mime
View raw message