When I try to delete an instance with a map in it I get this exception:
| java.lang.ClassCastException: java.util.HashMap cannot be cast to net.kaleidos.hibernate.postgresql.hstore.HstoreDomainType
at net.kaleidos.hibernate.usertype.HstoreType.deepCopy(HstoreType.java:56)
at org.hibernate.type.CustomType.deepCopy(CustomType.java:173)
at org.hibernate.type.TypeHelper.deepCopy(TypeHelper.java:68)
at org.hibernate.event.def.DefaultDeleteEventListener.createDeletedState(DefaultDeleteEventListener.java:301)
at org.hibernate.event.def.DefaultDeleteEventListener.deleteEntity(DefaultDeleteEventListener.java:252)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:162)
at org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:73)
at org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:956)
at org.hibernate.impl.SessionImpl.delete(SessionImpl.java:934)
at org.codehaus.groovy.grails.orm.hibernate.HibernateGormInstanceApi.delete_closure3(HibernateGormEnhancer.groovy:933)
at groovy.lang.Closure.call(Closure.java:415)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
at org.codehaus.groovy.grails.orm.hibernate.HibernateGormInstanceApi.delete(HibernateGormEnhancer.groovy:932)
at net.kaleidos.hibernate.hstore.PostgresqlHstoreDomainIntegrationSpec.save and delete a domain class with a map. key: #data(PostgresqlHstoreDomainIntegrationSpec.groovy:80)
I've added this integration test (which fails) in PostgresqlHstoreDomainIntegrationSpec.groovy:
@Unroll
void 'save and delete a domain class with a map. key: #data'() {
setup:
def testHstore = new TestHstore(testAttributes: data)
when: 'I save an instance'
testHstore.save(flush: true)
and: 'I try to delete it'
testHstore.delete(flush: true)
then: 'It shouldn\'t be present in database anymore'
TestHstore.count() == 0
where:
data | attribute | value
[foo:"bar"] | "foo" | "bar"
["foo,bar":"baz,qux"] | "foo,bar" | "baz,qux"
}
When I try to delete an instance with a map in it I get this exception:
I've added this integration test (which fails) in
PostgresqlHstoreDomainIntegrationSpec.groovy
: