@GeneratorType annotation #4427
Replies: 2 comments 14 replies
-
Ooops, I just noticed that what I've written up here is pretty much isomorphic to the already-existing So we should look for a way to unify these things. This isn't quite trivial given the structure of the current code, but it looks conceptually possible. I mean, I'm not saying we should get rid of the distinction between a @sebersole WDYT? |
Beta Was this translation helpful? Give feedback.
-
FTR, @sebersole has already implemented this proposal here: |
Beta Was this translation helpful? Give feedback.
-
Steve and I just discussed the question of configuring custom id generators, and we've converged on something I think works pretty well.
The problem we're trying to solve is the following:
@GenericGenerator
involves two levels of stringly-typed indirection.@Parameter
is even less typesafe.And we're making the assumption that most of the time we don't really need to share a single id generator between multiple entities, and it's just as good for the id generator to belong to a single entity.
The idea is to add a meta-annotation,
@GeneratorType
or whatever, that identifies an annotation type as specifying configuration properties for a custom id generator. For example:The custom id generator class consumes this annotation type in its constructor, something like:
Now, to make use of the custom id generator, I just annotate my
@Id
property:Note that all of the above is just to illustrate the ideas, and the details of this are still up for grabs.
Beta Was this translation helpful? Give feedback.
All reactions