Allow mapping from entity interfaces to entity #5

Closed
opened 2022-06-12 12:43:40 +02:00 by Dutch · 2 comments
Owner

Currently it is not possible to use interfaces as the target type of a relation, since RoomEx cannot know which entity corresponds to which interface.

Possible solutions:

  1. Check every entity if it implements that interface
    --> not good, since a interface good theoratically be used for multiple Entities
  2. Add an argument to all the relationship annotations to specifiy the correct entity
    --> maybe annoying on databases with many relations?
  3. Allow the definition of a map between interfaces and entities...
    --> ugly

Make 1. as the default option which can be overridden by option 2?

Currently it is not possible to use interfaces as the target type of a relation, since RoomEx cannot know which entity corresponds to which interface. Possible solutions: 1. Check every entity if it implements that interface --> not good, since a interface good theoratically be used for multiple Entities 2. Add an argument to all the relationship annotations to specifiy the correct entity --> maybe annoying on databases with many relations? 3. Allow the definition of a map between interfaces and entities... --> ugly Make 1. as the default option which can be overridden by option 2?
Author
Owner

Currently option 2 will be imlemented.

TODO:
Check if given entity class implements the specified interface

Currently option 2 will be imlemented. TODO: Check if given entity class implements the specified interface
Dutch referenced this issue from a commit 2022-06-24 16:05:05 +02:00
Dutch referenced this issue from a commit 2022-06-24 19:07:14 +02:00
Author
Owner

With the current implementation, this done by calls like:

resolvedType.declaration.closestClassDeclaration()!!.getAllSuperTypes().none { s -> s.declaration.qualifiedName!!.asString() == RoomExEntity::class.resolveName()

Which is not only verbose and error prone due to nullable types, it is also slow, since we are using "getAllSuperTypes()". Maybe there is a better solution for this?

With the current implementation, this done by calls like: ```kotlin resolvedType.declaration.closestClassDeclaration()!!.getAllSuperTypes().none { s -> s.declaration.qualifiedName!!.asString() == RoomExEntity::class.resolveName() ``` Which is not only verbose and error prone due to nullable types, it is also slow, since we are using "getAllSuperTypes()". Maybe there is a better solution for this?
Dutch added this to the Release v1.0 project 2022-12-20 18:17:00 +01:00
Dutch self-assigned this 2022-12-20 18:23:59 +01:00
Dutch added this to the v1.0 milestone 2022-12-20 18:41:53 +01:00
Dutch closed this issue 2023-01-06 14:46:51 +01:00
Commenting is not possible because the repository is archived.
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Dutch/RoomEx#5
No description provided.