th3an0maly
th3an0maly

Reputation: 3510

How to use NamedParameterJdbcTemplate to retrieve Decimal(4,2)

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

Answers (1)

andih
andih

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

Related Questions