Provided showcase for planned removal of @DocStore and @Inheritance #3210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello @rbygrave
in this PR I tried to provide some code, what we are actually doing with
@DocStore
and@Inheritance
We use a lot of
@DbJson
fields in our application, where we often store polymorph classes in these fieldse.g. we have an abstract "Report" in our ReportGeneratior that exists as different concrete instances,
or we have a "RepeatDefinition" when the report should be generated, here we have "RepeatDefinitionDaily/Weekly/Monthly" that can be configured to 1..n days/weeks/months or even a RepeatDefinitionWorkdays, that can be configured to 1..n workdays.
OK, there are always ways how to implement this without inheritance, e.g by an enum "RepeatDefinitionType" - but what to do, if there is the use case to add a repeat for "every holiday"
Ebean does a great job in classpath scan here, as I just need to add a
RepeatDefinitionHoliday extends RepeatDefinition
and overwrite the abstrat methodcomputeNextExecution
- I do not to extend enums or add@JsonSubType
to base classes.We also use the feature to reference other entities from JSONs, that was provided by me in #1158
To get
@DbJson
working properly with@DocStore
we needed some glue logic, to redirect Jackson-serialization back to EbeanI could imagine a possible migration plan like this
@DocStore
annotation will be replaced by something called@JsonEntity
@Inheritance
,@DiscriminatorColumn
and@DiscriminatorValue
we would need similar annotations. e.g.@JsonBaseType(property="kind")
as replacement for@Inheritance
,@DiscriminatorColumn
and optional@JsonTypeName
for@DiscriminatorValue
@DbJson
fields and uses the built in serialization, maybe we can use@JsonEntity(useBuiltinSerialization = true)
or@DbJson(useBuiltinSerialization = true)
Note: This PR is for discussion in #3112 and I do not expect, that it gets merged in this form