How to implement a custom basic type using Hibernate UserType

Introduction In this article, we are going to see how we can implement a custom type using the Hibernate UserType interface. If you wonder why you’d ever want to do this, then check out this question. Our Hibernate user wants a resilient CharacterType that works with NULL or empty values. To make it even more interesting, we are going to make it work even if the underlying database column contains more than one character.