Skip to content

6.1 - GrailsEntityDirtinessStrategy ClassCastException with hibernate-envers #895

@zyro23

Description

@zyro23

grails-3.2.8 / gorm-6.1.0.RELEASE.

...
Caused by: java.lang.ClassCastException: Cannot cast java.util.HashMap to org.grails.datastore.mapping.dirty.checking.DirtyCheckable
	at java.lang.Class.cast(Class.java:3369)
	at org.grails.orm.hibernate.dirty.GrailsEntityDirtinessStrategy.cast(GrailsEntityDirtinessStrategy.groovy:94)
	at org.grails.orm.hibernate.dirty.GrailsEntityDirtinessStrategy.access$0(GrailsEntityDirtinessStrategy.groovy)
	at org.grails.orm.hibernate.dirty.GrailsEntityDirtinessStrategy$1.isDirty(GrailsEntityDirtinessStrategy.groovy:65)
	at org.hibernate.event.internal.DefaultFlushEntityEventListener$DirtyCheckAttributeInfoImpl.visitAttributes(DefaultFlushEntityEventListener.java:632)
	at org.hibernate.event.internal.DefaultFlushEntityEventListener$1DirtyCheckContextImpl.doDirtyChecking(DefaultFlushEntityEventListener.java:496)
	at org.grails.orm.hibernate.dirty.GrailsEntityDirtinessStrategy.findDirty(GrailsEntityDirtinessStrategy.groovy:58)
	at org.hibernate.event.internal.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:503)
	at org.hibernate.event.internal.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:215)
	at org.hibernate.event.internal.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:142)
	at org.hibernate.event.internal.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:216)
	at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:85)
	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:38)
	at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1295)
	at org.hibernate.envers.internal.synchronization.AuditProcess.doBeforeTransactionCompletion(AuditProcess.java:156)
	at org.hibernate.envers.internal.synchronization.AuditProcessManager$1.doBeforeTransactionCompletion(AuditProcessManager.java:46)
	at org.hibernate.engine.spi.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:928)
...

envers audit entries (_AUD table rows) are passed through the dirty check as a map.
debugging to https://github.com/grails/grails-data-mapping/blob/v6.1.0/grails-datastore-gorm-hibernate-core/src/main/groovy/org/grails/orm/hibernate/dirty/GrailsEntityDirtinessStrategy.groovy#L94 for a simple Role entity that has just a String name property and is being audited looks like:

this = {GrailsEntityDirtinessStrategy@13021} 
entity = {HashMap@13314}  size = 4
 0 = {HashMap$Node@13318} "name" -> "ROLE_ADMIN"
 1 = {HashMap$Node@13319} "originalId" -> " size = 2"
 2 = {HashMap$Node@13320} "version" -> "1"
 3 = {HashMap$Node@13321} "REVTYPE" -> "ADD"

no more error after i reverted back to hibernate.hibernateDirtyChecking: true (application.yml)

thanks, zyro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions