Hi Otavio!
The principal problem is that standard JSONB / JPA / JNoSQL
polymorphism is not enough for some JSON schemas.
When I have "oneOf": [], the spec. says that json must match at
most one schema.
In my particular case I have a MeasurementValueEntity and
ComplexValueEntity, OntologyTermValueEntity and QuantityEntity
that inherit from it.
So basically I'd like to catch MeasurementValueEntity with
MeasurementValueReader, manually decide which of three types
should be instantiated and
return it. I just see no API to do this. Something like in JAXB:
jsonb.fromJson(value, OntologyTermValueEntity.class);
I mean - I have Object value and know the Entity class and want
create the Entity object.
Kind regards,
Dmitry
On 6/27/2024 10:00 AM, Otavio Santana
wrote:
Hey Dmitry, how are you?
We are doing well and thanks for all support and feedback,
you are a great contributor!
About having not discriminator value, could you create a
scenario?
This way, we can work together on this solution.
Hi
all,
Great to see that spec. and implementation is moving forward.
Especially that annotations are moving to the spec.:
org.eclipse.jnosql.mapping.Inheritance ->
jakarta.nosql.Inheritance
Nevertheless, I have a trouble with custom inheritance with
1.1 using
ValueReader.
The implementation has changed (was Document and its an
Element now).
Is there an elegant way to implement the inheritance when I
have no
discriminator field?
public class MeasurementValueReader implements ValueReader {
@Override
public <T> T read(Class<T> clazz, Object
value) {
if (List.class.isInstance(value)) {
final List list = List.class.cast(value);
if (list.stream().filter(Entry.class::isInstance)
.anyMatch(e ->
"unit".equals(((Entry)e).name()))) {
return (QuantityEntity) ???;
}
}
How may I manually convert Object value into the concrete
(QuantityEntity) type (I catch the "Measurement" interface).
Thank you in advance,
Dmitry
_______________________________________________
nosql-dev mailing list
nosql-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/nosql-dev
--