Reputation: 3510
I'm trying to use NamedParameterJdbcTemplate
to retrieve a Decimal(4,2)
value from the DB. Had it been an int
value, I could've done NamedParameterJdbcTemplate.queryForInt()
but I dont find a similar function for retrieving a Decimal. Please help.
Upvotes: 2
Views: 2877
Reputation: 5603
You can use the queryForObject
method of the NamedParameterJdbcTemplate
// Thanks to Mark Rotteveel
BigDecimal result = (BigDecimal)template.queryForObject("select 1.0 from dual", new HashMap(), java.lang.BigDecimal.class);
Upvotes: 3