How to trouble-shoot GORM/Hibernate UserType mapping

I am making a change to a large and mature GORM/Hibernate based system to ‘lift out’ one of the entities from database to a different persistence store, without impacting the application code as far as practically possible. I doing this by leaving the foreign key references to the ‘lifted out’ entity in place in the GORM managed entities and plugging in a ‘UserType’ to map from the remaining foreign key column to the lifted out entity.

For one-to-many relationships from GORM entities to the lifted out entity I’ve marked the previously GORM managed Collections members as ‘transient’ and added ‘def afterLoad()’ methods to their GORM domain classes populate the collections from the non-GORM persistence store…

BUT, it doesn’t work as expected, and I would really appreciate any suggestions on how to go about trouble-shooting this. On startup when I believe GORM is configuring Hibernate with the mapping configuration it needs, the system seems to go into some kind of busy-loop until failing after about 30 minutes with no actual error.

When I started testing I was using Hibernate 5.4.28 and that failed with an OOM error, and the heap dump indicated that the TypeConfigurationRegistry had become huge. On investigation I found that a memory leak had been reported in this and that it had been fixed/removed in 5.5. So I upgraded to Hibernate 5.6.10.Final, and now the OOM has gone, but as I said, it appears to be in some kind of loop during startup until it fails. So I suspect that the loop was there earlier and filled up the TypeConfigurationRegistry and the upgrade fixed the memory leak, but the looping behaviour, no doubt a result of something I’ve done wrong, or not done at all, is the root cause…

I enabled logging, on all of Hibernate and GORM, but can make little sense of the output - other than it appears to be repeating itself over an over. I have put conditional break points in every place i can find UserType being referenced in Hibernate, and can find no use of my new user-defined UserType, suggesting that the GORM DSL expression to map the foreign key columns to this type aren’t resulting in a Hibernate UserType at all. All I see is lots of other ‘basic’ and application enum types being registered over and over again.

I would much appreciate any guidance anyone can offer.

This is the first time I hear of something like that, so my guess is that this has to be related to GORM. If you can provide a reproducer application, I can look into it, but without that, there is not much I can help you with, especially since I think this is probably not a problem in Hibernate ORM.

Thank you for your reply and offer Beikov, but I agree, it’s unlikely to be a problem with Hibernate itself, but either with GORM (or rather how I’m using it). I’m hoping there might be someone out there with GORM specific experience of using a UserType via the GORM DSL, that in turn drives Hibernate, who can point me towards how I can check the expected effect of the Groovy/GORM level enrichment of the domain/entity classes on the dynamically generated Hibernate config.