-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Entity view inheritance with polymorphic depth 3 has too restrictive type constraints #475
Comments
I merely removed the second Nevertheless, I think it would in as sense be most logical to stay as close as possible to the behaviour of JPAs
Thus I would find it logical that:
Given that |
The thing is, if at some point |
Ah I see the problem. I forgot about that case as Hibernate does not allow subtypes to be filtered in such a manner.
I hope class hierarchies don't get any more complex than everything we can imagine to support now. Being able to override the considered subtypes for a subview type might be something that could be implement, but I find it very vague and ambiguous how it should work and why this would not have side effects for its super entity view . Agreed? |
So to make this clear: @EntityView(A.class)
@EntityViewInheritance
public inteface AView {...}
@EntityView(B.class)
public inteface BView extends AView {...}
@EntityView(C.class)
public inteface CView extends BView {...} When querying for and the case: @EntityView(A.class)
@EntityViewInheritance({ AView.class, CView.class })
public inteface AView {...}
@EntityView(B.class)
public inteface BView extends AView {...}
@EntityView(C.class)
public inteface CView extends BView {...} When querying for finally in the case: @EntityView(A.class)
@EntityViewInheritance({ AView.class, CView.class })
public inteface AView {...}
@EntityView(B.class)
@EntityViewInheritance({ })
public inteface BView extends AView {...}
@EntityView(C.class)
public inteface CView extends BView {...} When querying for Is that what you would expect? |
I think so yes. Its still a little confusing, but I think this makes the most sense! |
The alternative could be: @EntityView(A.class)
@EntityViewInheritance
public inteface AView {...}
@EntityView(B.class)
public inteface BView extends AView {...}
@EntityView(C.class)
public inteface CView extends BView {...}
@EntityView(D.class)
public inteface DView extends BView {...} When querying for and the case: @EntityView(A.class)
@EntityViewInheritance({ AView.class, CView.class })
public inteface AView {...}
@EntityView(B.class)
public inteface BView extends AView {...}
@EntityView(C.class)
public inteface CView extends BView {...}
@EntityView(D.class)
public inteface DView extends BView {...} When querying for finally in the case: @EntityView(A.class)
@EntityViewInheritance({ AView.class, CView.class })
public inteface AView {...}
@EntityView(B.class)
@EntityViewInheritance({ BView.class, CView.class })
public inteface BView extends AView {...}
@EntityView(C.class)
public inteface CView extends BView {...}
@EntityView(D.class)
public inteface DView extends BView {...} When querying for The difference is, that regardless of the content of the |
The alternative inherits the I think the alternative makes sense only if |
Currently the behavior(after the bug fix) is like this: @EntityView(A.class)
@EntityViewInheritance
public inteface AView {...}
@EntityView(B.class)
public inteface BView extends AView {...}
@EntityView(C.class)
public inteface CView extends BView {...}
@EntityView(D.class)
public inteface DView extends BView {...} When querying for and the case: @EntityView(A.class)
@EntityViewInheritance({ AView.class, CView.class })
public inteface AView {...}
@EntityView(B.class)
public inteface BView extends AView {...}
@EntityView(C.class)
public inteface CView extends BView {...}
@EntityView(D.class)
public inteface DView extends BView {...} When querying for finally in the case: @EntityView(A.class)
@EntityViewInheritance({ AView.class, CView.class })
public inteface AView {...}
@EntityView(B.class)
@EntityViewInheritance({ BView.class, CView.class })
public inteface BView extends AView {...}
@EntityView(C.class)
public inteface CView extends BView {...}
@EntityView(D.class)
public inteface DView extends BView {...} When querying for So currently, for every entity view type that you query, it is required that an |
And the case: @EntityView(A.class)
@EntityViewInheritance({ AView.class, CView.class })
public inteface AView {...}
@EntityView(B.class)
@EntityViewInheritance()
public inteface BView extends AView {...}
@EntityView(C.class)
public inteface CView extends BView {...}
@EntityView(D.class)
public inteface DView extends BView {...} When querying for AView, you can get instances of types: AView and CView That works for me! |
Correct, that's the current behavior. |
Is that fix already on the remote? 😄 |
Here is the fix: #478 |
👍 |
Currently the entity view inheritance for polymorphic models with depth 3 generates type constraints for the type discriminator that are contradictory like
TYPE(this) = B AND TYPE(this) = C
when C > B > A.The test is provided in #465 which is easily fixed by simply not adding type constraints for proper entity super types.
However there is a testcase that assumes
BView
which doesn't have@EntityViewInheritance
annotated will also use entity view inheritance. I'm not sure what the default should be, maybe @jwgmeligmeyling could argue for one or the other? If we enable inheritance by default just because a super type added the@EntityViewInheritance
annotation, every entity view subtype that shouldn't use inheritance by default would have to annotate@EntityViewInheritance({THIS_TYPE.class})
to disable inheritance.If we don't enable this by default, people have to annotate
@EntityViewInheritance
explicitly in this case onBView
. What do you say?The text was updated successfully, but these errors were encountered: