I’m using SQLite + Hibernate in my JAVA app. I’m getting an error java.sql.SQLException: Bad value for type BigDecimal
while executing a SQL query using hibernate’s NativeQueryImpl
class. Below is my code which I’m using
public List<Map<String, Object>> executeNativeQuery(String query) {
NativeQueryImpl nativeQuery = (NativeQueryImpl) entityManager.createNativeQuery(query);
nativeQuery.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);
return nativeQuery.getResultList();
}
I’m calling executeNativeQuery function by passing a SQL query and getting the error at the line return nativeQuery.getResultList();
. Looks like somewhere while extracting the result hibernate is trying to extract String value as BigDecimal.
Exception log
java.sql.SQLException: Bad value for type BigDecimal : An elegant piece with blue and white Zircon stones studded like a scintillating star-shaped evil eye to ward off the negative vibes. Available in Silver and Rose Gold Plating. 92.5 Sterling Silver AAA Cubic Zirconia Handcrafted and Electroplated with Rhodium for strength and luster. Consciously crafted with non-allergic materials, thus making it hypoallergenic. 92.5 Sterling Silver Authenticity Certificate included. All our jewellery is handcrafted and therefore variations may occur.\n\tat org.sqlite.jdbc3.JDBC3ResultSet.getBigDecimal(JDBC3ResultSet.java:190)\n\tat org.sqlite.jdbc3.JDBC3ResultSet.getBigDecimal(JDBC3ResultSet.java:199)\n\tat com.zaxxer.hikari.pool.HikariProxyResultSet.getBigDecimal(HikariProxyResultSet.java)
Hibernate Version : 5.4.25.Final
SQLite JDBC driver
implementation("org.xerial:sqlite-jdbc:3.36.0.3")
SQLite Dialect
implementation("com.github.gwenn:sqlite-dialect:0.1.0")
And one more thing this is not failing for all queries of the same kind. It would be really helpful if I get any help here