Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [nosql-dev] Polymorthism help needed.

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.

On Wed, Jun 26, 2024 at 11:24 AM Dmitry Repchevsky via nosql-dev <nosql-dev@xxxxxxxxxxx> wrote:
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


--

Thanks a lot,

Twitter | Linkedin | Youtube


Back to the top