Closed ilopmar closed 10 years ago
Related unit tests don't pass yet:
| Failure: map with key of type different to String. key: 123(net.kaleidos.hibernate.usertype.HstoreHelperSpec)
| java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at net.kaleidos.hibernate.usertype.HstoreHelper.toString(HstoreHelper.java:28)
at net.kaleidos.hibernate.usertype.HstoreHelperSpec.map with key of type different to String. key: #key(HstoreHelperSpec.groovy:175)
| Running 16 spock tests... 39 of 16
| Failure: map with key of type different to String. key: true(net.kaleidos.hibernate.usertype.HstoreHelperSpec)
| java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
at net.kaleidos.hibernate.usertype.HstoreHelper.toString(HstoreHelper.java:28)
at net.kaleidos.hibernate.usertype.HstoreHelperSpec.map with key of type different to String. key: #key(HstoreHelperSpec.groovy:175)
| Running 16 spock tests... 40 of 16
| Failure: map with key of type different to String. key: 999(net.kaleidos.hibernate.usertype.HstoreHelperSpec)
| java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at net.kaleidos.hibernate.usertype.HstoreHelper.toString(HstoreHelper.java:28)
at net.kaleidos.hibernate.usertype.HstoreHelperSpec.map with key of type different to String. key: #key(HstoreHelperSpec.groovy:175)
| Running 16 spock tests... 41 of 16
| Failure: map with key of type different to String. key: Wed Feb 12 15:47:16 CET 2014(net.kaleidos.hibernate.usertype.HstoreHelperSpec)
| java.lang.ClassCastException: java.util.Date cannot be cast to java.lang.String
at net.kaleidos.hibernate.usertype.HstoreHelper.toString(HstoreHelper.java:28)
at net.kaleidos.hibernate.usertype.HstoreHelperSpec.map with key of type different to String. key: #key(HstoreHelperSpec.groovy:175)
| Running 16 spock tests... 42 of 16
| Failure: map with key of type different to String. key: 87987.8976(net.kaleidos.hibernate.usertype.HstoreHelperSpec)
| java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.String
at net.kaleidos.hibernate.usertype.HstoreHelper.toString(HstoreHelper.java:28)
at net.kaleidos.hibernate.usertype.HstoreHelperSpec.map with key of type different to String. key: #key(HstoreHelperSpec.groovy:175)
| Completed 42 spock tests, 5 failed in 182ms
I think this issue is related to 'toString' method signature in HstoreHelper
, it should be toString(Map<Object, String> m)
, since it already handles key conversion to String internally.
Seems that the toString(Map<String, String> m)
signature forces a cast when the method is called.
Woow! Thank you very much :-)
When we use a value of type different from String as Hstore key we get the following error: