Accessing database in UserType call-back...?

I am using the Hibernate (with Grails/GORM) feature to map a columns to a custom type. In my custom UserType implementation the method to handle the column value (nullSafeGet) accesses a Grails DataService, (which I believe entails invocation of a Spring transaction boundary call). However this is proving to be problematic in that after the successful call to this Data service the handling of other columns in the ResultSet is failing with a JDBC/Postgresql error that the ResultSet is closed. My suspicion is that the call to this other Data service may be causing this side effect and that I should avoid any other database calls in this call-back. However before I look into changing the design I thought it worth reaching out here to see if anyone can confirm my hypothesis and suggest any other workarounds other than avoiding further database access.

In summary, in a UserType#nullSafeGet call is it safe to invoke a database operation?

You’d have to share the version and configuration that you are using in order for anyone to be able to help you. I guess that if you’re using the ConnectionReleaseMode.AFTER_STATEMENT, then you might be seeing something like this. I don’t know how Spring works, but even with AFTER_TRANSACTION you might see this behavior if your query started before the transaction on the same Session.

Thanks for the reply. I have changed the design to avoid the issue.