UserType #3959
Replies: 4 comments 3 replies
-
For the sake of backwards compatibility, keeping |
Beta Was this translation helpful? Give feedback.
-
Do you think we can get rid of |
Beta Was this translation helpful? Give feedback.
-
On the broader question, I would be inclined to retain |
Beta Was this translation helpful? Give feedback.
-
One use case for UserType that I know of is to define how to map business "wrapper" types. For example Attribute converters only get you halfway there, since you don't get to define the SQL type, only the java type. I suppose one could define the default SQL type for |
Beta Was this translation helpful? Give feedback.
-
UserType
UserType
will have to change. Users will have to change their impls. That's not avoidable.They will need to change to handle the overall move from reading by name to reading by position from the JDBC
ResultSet
. Also, they will need to change to account for the fact that BasicTypes are now limited to a single JDBC type.Given that, we have some flexibility to improve the contract. As minimally as possible, ofc.
In what cases do we intend
UserType
to be used? In cases where there is a "conversion"? In cases describing a non-baselineJavaTypeDescriptor
? This helps determine what we need fromUserType
. We have@JavaType
,@JavaTypeRegistration
,@JdbcType
,@JdbcTypeCode
,@JdbcTypeRegistration
,@Convert
, etc. Why UserType instead of a combination of those? One argument for keepingUserType
is for users who would rather bundle all of that processing into a single thing to register.compared to
JavaTypeDescriptor
UserTypes mapping Java types not known to the
JavaTypeDescriptorRegistry
cause problems in numerous cases.A simple solution would be to auto-register a
JavaTypeDescriptor
wrapping theUserType
for the mapped Java type. UserType has all of the information we need to implementJavaTypeDescriptor
, includingMutabilityPlan
. However, this causes problems when multiple UserTypes get registered for the same Java type...Maybe we restrict one UserType per Java type? Otherwise we will need to have
UserType
provide us theJavaTypeDescriptor
to use, not justUserType#returnedClass
Conversion
UserTypes also sometimes (usually?) implement some form of conversion. When is having UserType better for that?
Beta Was this translation helpful? Give feedback.
All reactions