[hibernate-dev] boolean type support
Steve Ebersole
steve at hibernate.org
Fri Jan 27 11:31:05 EST 2017
Another thing we run into in 6.0 dev is handling booleans, specifically in
regards to dealing with the database representation (0 or 1, versus 'T' of
'F', versus ...).
The way we handle this today (pre-6.0) is to "fake it" by registering a
JavaTypeDescriptor for each representation combo[1]. We can obviously
continue to do it this way.
But in moving forward we wanted to take a step back and look at this
again. And really this is the kind of scenario that AttributeConverters
are designed to handle. So we are considering to instead actually handle
this via an AttributeConverter. To fully understand this remember that we
have also moved AttributeConverter tracking on to the attribute[2] itself
as opposed to "baking it" into a Type. In that way it would just be
handled by the "type system" to automatically add an AttributeConverter to
the attribute.
Obviously that only works if there is not already an AttributeConverter
applied to to the attribute. I cannot imagine that ever happens in a
supported way, or a way that we want to support. Essentially that would
mean a condition where we convert the value twice in each direction. But
in case we miss some ase, I wanted to ask the list.
[1] Yes, it seems odd that this is handled in the JavaTypeDescriptor. The
reason it happens that way is that it is incorporated into the wrap/unwrap
code.
[2] I say "attribute" just a a means of simplification. It is really a
Navigable which is new concept and probably not well known to everyone..
More information about the hibernate-dev
mailing list