Our custom user type depends on a few collaborators. We're using Spring dependency injection elsewhere in our Grails application, and it would be ideal to use it for the UserType.
We'd be using constructor-based injection
Code:
public class MyUserType implementsUserType {
public MyUserType(Collaborator collaborator, AnotherCollaborator, anotherCollaborator) {
// ...
}
}
My understanding is that as a consumer of hibernate, we have no guarantees about when or where hibernate will instantiate UserTypes: certainly it is outside of our container.
My question:
Is there a way for us to control how our UserType is instantiated, perhaps a factory or some other builder class?