Hello Hibernate People,
I implemented a custom user type to map boolean values to database values. When I execute a query with the following criteria, I get an exception, that tells me that the user type cannot be casted to EnhancedUserType:
CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder(); ... criteriaBuilder.isTrue(root.get("imported"))
The imported property is a boolean value mapped with this user type.
However, when I change the criteria using equal() instead of isTrue() it works:
So I have the following questions:
- Why do I need to implement EnhancedUserType when I use isTrue()?
- Is there an advise how to implement the interface EnhancedUserType correctly?
- Two methods of this interface are deprecated. Does this mean, that this methods are not called by Hibernate anymore and may return null?
- I found some articles, which implement the method objectToSQLString() so that it returns the string value enclosed in single quotes. Is this the right way to do it?
Unfortunately the JavaDocs of this interface is not very helpful.