I am returning to a challenge that first brought me to this forum in the middle of last year, that of exploiting Hibernate’s UserType mechanism for plugging in ones own handling of certain database table columns. I received some useful guidance then and was successful in creating a proof of concept so am hopeful I might receive some further assistance this time.
This time around I am using a slightly different approach but the target system is the same, being a large monolith application with nearly 300 tables, written using Grails and GORM/Hibernate. I have established what appears to be a reliable recipe for lifting out certain entities from the scope of GORM and changing the ‘GORM mapping’ annotation that in turn configures Hibernate to use the UserType class that I supply to take care of consuming or providing the values in the relevant columns.
This work progressed well until I have encountered an exception when applying this recipe to a new entity which indicates I’ve done something wrong. The exception is of the form:
org.springframework.orm.hibernate5.HibernateSystemException: Could not set field value [DocumentType3_groovyProxy@656efa62] value by reflection : [class a.b.HibernateMappedClass.documentType] setter of a.b.HibernateMappedClass.documentType; nested exception is org.hibernate.PropertyAccessException: Could not set field value [DocumentType3_groovyProxy@656efa62] value by reflection : [class a.b.HibernateMappedClass.documentType] setter of a.b.HibernateMappedClass.documentType
at org.springframework.orm.hibernate5.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:267)
at org.grails.orm.hibernate.GrailsHibernateTemplate.convertHibernateAccessException(GrailsHibernateTemplate.java:717)
Where HibernateMappedClass represents the Domain/Entity class that is the subject of ORM, and ‘documentType’ is a property within that class that is handled by a UserType subclass.
I_think_ that this is occurring at the point where a row from the table has been read and the value from the user defined column has been retrieved and is in ‘DocumentType3_groovyProxy@656efa62’, and ready to be assigned to the appropriate property of the ‘HibernateMappedClass’. But some check is failing that is preventing that assignment from occurring.
I’ve looked quite carefully and can’t see anything that would prevent this property from being settable.
Any suggestions very welcome of how I might dig deeper into this…