The following line works incorrect with Java 8.
(Map<Integer, BigDecimal>) resultSet.getObject("hstore_field");
hstore key and value are stored as text in the Postgres DB. Despite the fact the object received from resultSet is casted to Map<Integer, BigDecimal>
and no warnings/errors received during compilation time, data persisted in HashMap is of type <String, String>
.
I have tested with instanceof BigDecimal and got false.
More interesting lambda way failed at runtime when doing
hstoreMap.foreach((k,v)-> System.out.println(k + " " +v));
So,the problem is clear - casting does not work this way. Therefore I casted to Map and then converted map to required type. Anyway, is this kind of bug?
I'm not 100% sure, but here's what I was able to find for you:
http://www.postgresql.org/message-id/4FAB8796.40904@nitorcreations.com
It looks like hstore support is still limited to HashMap<String, String>
wrapper object. I would not call it a bug anyway.