@CustomType #4266
Replies: 8 comments 38 replies
-
|
Beta Was this translation helpful? Give feedback.
-
What would be the solution for automatically applying a custom type to a given class? We used to have Thinking about it, shouldn't the solution be similar to |
Beta Was this translation helpful? Give feedback.
-
Depending on exactly what the custom UserType did...
|
Beta Was this translation helpful? Give feedback.
-
@sebersole I don't think I like this |
Beta Was this translation helpful? Give feedback.
-
No I like it. It helps solve the fugly annotations-dont-have-inheritance-so-we-need-to-wrap-the-annotation-we-are-interested-in-within-other-annotations. In other words, I find this nicer
than
at least from the perspective of implementing support for it. In my opinion its arguable which is better from a user perspective and some will prefer one while others prefer the other. But the one argument for it as-is is consistency with JPA e.g. with And keep in mind, its not just
|
Beta Was this translation helpful? Give feedback.
-
As I played with prototyping this (and porting tests, especially) I wonder if it is worthwhile to still provide a
As well as adjusting
Coming back to the enum point.. as I mentioned, I think it depends on what we want to support. 2 things in particular I'd like to support that we need to consider here:
And of course it depends how we want to support those. For discriminator, e.g, do we add a For overrides, the difference comes back to needing to supply open-ended values (i.e. actual attribute names) Don't know the answers yet; just some thoughts that ran through my head as I started implementing this |
Beta Was this translation helpful? Give feedback.
-
So I changed my mind a bit. I (and I think all of us) would preferred annotations to be able to implement a common interface, but it ofc does not. So the next best thing is to use the nested annotation approach. We can look at the type-use approach later as a possible improvement. So I'll do:
Though, even this might be better to allow for adding addition mapping details
|
Beta Was this translation helpful? Give feedback.
-
Going to make a change as I got into implementing this... First, I am going to drop:
Then define
And then:
|
Beta Was this translation helpful? Give feedback.
-
TLDR; Introduce
@CustomType
as a type-safe replacement for@Type
.https://hibernate.atlassian.net/browse/HHH-14856
We've had a few discussions now about wanting to move away from Type determination being based on Strings and to define a more type-safe way to accomplish that.
I propose the following annotation:
With regard to
#attributeName
, it was suggested by @beikov and I think its a great idea. Rather than needing additional annotations such as@MapKeyCustomType
, etc we can just have a single annotation and specify what the type applies to. This follows the pattern used by JPA so that's good(ish)I also propose that we drop
@Type
,@MapKeyType
,@TypeDef
,@TypeDefs
as part of this work. We have better ways for users to accomplish these, so there is good migration story. KeepingUserType
and providing@CustomType
covers the remaining cases where people want/have to continue to use UserType impls. And it gets us out of the String-based resolution at all. Well, from annotations at least.Beta Was this translation helpful? Give feedback.
All reactions