Question

I recently got the latest version of Hibernate and noticed that my UserTypes now have warnings about AbstractStandardBasicType's nullSafeGet(ResultSet,String) and nullSafeSet(PreparedStatement,T,int) methods being deprecated in favor of their corresponding methods that take a SessionImplementor argument. The problem is that when you implement a UserType, the SessionImplementor doesn't get passed to you the way that is does in BasicType, CompositeUserType, etc.

I checked the Hibernate manual to see if there was an updated example. Their UserType example uses get/set instead of nullSafeGet/nullSafeSet, but those methods were also deprecated in favor of versions that take a SessionImplementor. So, it seems like even Hibernate's official UserType example is using deprecated methods, which leads me to wonder two things:

  1. Is there a good way to get the SessionImplementor from within the UserType?
  2. If it isn't practical to get the SessionImplementor from within UserType, and I don't want to write my own nullSafeGet/nullSafeSet, should I abandon UserType in favor of one of its alternatives? What are the practical differences between UserType and, for example, BasicType?
Was it helpful?

Solution

Thanks to Ryan Ransford for his comment on my original question. Although it's not really a solution to the problem, the link he provided from the Hibernate developers mailing list explains why no solution is available.

A non-deprecated alternative cannot be provided in 3.6.x, because doing so would break implementations of UserType.

Considering that these are just deprecation warnings, it doesn't make sense to invest too much time in a workaround that will be obsolete when the next non-maintenance release is available. Unfortunately, the next big release is 4.0, not 3.7, so migrating might be a little more involved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top