sqlite-jdbc: java.sql.SQLException: Bad value for type BigDecimal

Describe the bug While extracting ResultSet JDBC driver is trying to extract String as BigDecimal

To Reproduce This is failing only for some SQL queries and working fine for other queries of same kind. Looks like driver is not properly guessing data type of a value

Logs 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)

Environment

  • SQLite JDBC driver - implementation(“org.xerial:sqlite-jdbc:3.36.0.3”)
  • SQLite Dialect - implementation(“com.github.gwenn:sqlite-dialect:0.1.0”)

Additional context I’m using SQLite + Hibernate in my JAVA app. While executing a SQL query using hibernate’s NativeQueryImpl class I’m getting the above mentioned exception. 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(); I thought the error is related to hibernate and raised the issue in their forum, but they thought it is not related to hibernate and redirected me here.

It would be really helpful if I get any help here

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27

Most upvoted comments

I’ll keep this open, I think we could fix this in the driver, but I hadn’t had any time to try to do a repro on my end.

Can I contribute towards fixing this?

When I have time I will try to reproduce this in a unit test. If I can’t I may ask you for more details or data.

You should have started by saying this, that would have helped