PDA

View Full Version : MappingSqlQuery and a custom ExceptionTranslator?



bkrapf
03-19-2008, 05:43 PM
I am doing data access with JdbcTemplate and using setExceptionTranslator to set it to a custom exception translator that I have written. I am then using the JdbcTemplate.query(String sql, RowMapper rowMapper) to execute select statements.

However, I would like to change this to use MappingSqlQuery. I have classes that extend MappingSqlQuery that take in a Datasource in the constructor. I have this setup and it works great, but this doesn't seem to use JdbcTemplate at all, and I don't see any way to set an ExceptionTranslator on MappingSqlQuery. How can I use MappingSqlQuery with my custom ExceptionTranslator?

Mark Pollack
03-27-2008, 09:15 PM
Hi,

MappingSqlQuery inherits from RdbmsOperation, which as a property setJdbcTemplate. You can use that to configure your MappingSqlQuery to use the jdbcTemplate configured with your exception translator. BTW, this is the Spring.NET forum, Java related questions should be posted at http://forum.springframework.org

Cheers,
Mark