Skip to content
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

Inverse relationship hooks not triggering for polymorphic types #3172

Closed
bladedancer opened this issue Mar 7, 2024 · 1 comment · Fixed by #3173
Closed

Inverse relationship hooks not triggering for polymorphic types #3172

bladedancer opened this issue Mar 7, 2024 · 1 comment · Fixed by #3173

Comments

@bladedancer
Copy link
Contributor

Expected Behavior

When deleting an entity in the many side of a oneToMany it triggers an update on the one side due to the relationship being updated. This can be used to trigger lifecycle hooks.

However in a polymorphic case (https://elide.io/pages/guide/v7/02-data-model.html#inheritance) when you delete the many side of the relationship the hooks don't trigger.

Current Behavior

The problem is due to how the relation inverse is performed.
https://github.com/yahoo/elide/blob/master/elide-core/src/main/java/com/yahoo/elide/core/dictionary/EntityDictionary.java#L732

It's doing getParameterizedType(inverseType, inverseRelationName).equals(clsBinding.entityClass)
The problem is getParameterizedType is returning the base class, clsBinding.entityClass is the derived type...so equals is false.

Possible Solution

Moving from equals to isAssignableFrom seems to be a feasible solution.

Steps to Reproduce (for bugs)

I'll attach a pull request with updated unit tests.

Context

The lifecyclehooks are not firing on the one side of the relationship because the inverse relationship is returning an empty string.

Your Environment

  • Elide version used: 7.0.2
  • Environment name and version (Java 1.8.0_152): openjdk 17.0.6 2023-01-17 LTS
  • Operating System and version: Ubuntu/Alpine
@aklish
Copy link
Member

aklish commented Mar 18, 2024

Thanks for the submission. Will review soon.

aklish pushed a commit that referenced this issue Mar 23, 2024
* Inverse relationship type calculation (#3172)

* Sytle fixes.

---------

Co-authored-by: Gavin Matthews <gmatthews@axway.com>
Doom9527 pushed a commit to paion-data/elide that referenced this issue Apr 3, 2024
* Inverse relationship type calculation (yahoo#3172)

* Sytle fixes.

---------

Co-authored-by: Gavin Matthews <gmatthews@axway.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants