-
Notifications
You must be signed in to change notification settings - Fork 116
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 Inheritance #249
Comments
Docs are updated. Now, let's leave that issue as a feature request to track interest. |
Wonder what's the behavior in Dart with model inheritance? Say I have a Base class (which is not annotated, so it's not persisted as documented) and a Sub class (annotated with @entity) that extends from the Base class. So the properties defined in Sub are persisted as for a normal entity and the inherited properties from Base are not persisted. Is this correct? |
Better a late answer then none :) @LeoK987
Yes, that's what happens. You can see it in action here: https://github.com/objectbox/objectbox-dart-performance/blob/main/lib/model.dart |
Currently in Dart, is there a [trick] way where the base class as well as the subclass' properties are persisted as one entity? (namely as the subclass). If not, would it help that I define the entity relationships in Java, but you still generate dart code from it? |
It would be helpful to have this feature in dart as well. Is there any work around to have an abstract class defined in the Entity class in a 1:1 relationship. For example
basically in my case the nested child in json structure has different key value pairs and I cannot save it as Map |
This comment was marked as spam.
This comment was marked as spam.
I also need this feature to be able to implement common fields on multiple entities |
This comment was marked as spam.
This comment was marked as spam.
I don't understand why this is available on the other platforms but not in Dart/Flutter. It's the correct way to share multiple fields in different entities... |
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
Please thumbs up the original post, this helps us track interest! |
This feature is pretty important to comply with the DRY principle and ensure that some type of entities have specific properties , especially in bigger projects with lots of entities. Looking forward to an implementation! 👍🏽 Only Workaround I see for now is using getter and setter and implementing them, like @vaind mentioned in here :
|
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
If you are interested in this please thumbs up the original post, this helps us track interest! |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
For this issue, the goal and how to get there is clear. Thus, further conversations will be locked to prevent people just indicating interest: this should be done via 👍 at the issue description at the top ⬆️. This is the best way to track interest. |
Unlocked so people can thumbs up the first post if interested! Note: from a software engineering perspective it is a good idea not to have inheritance in your model files. It may seem to make things easier at first (less code, faster time to implement), but can lead to issues later (model changes, hard to uncouple). Anyhow, as said, if interested, thumbs up the first post! This helps us track interest. |
Is Entity Inheritance already supported?
@BaseEntity
annotation seems not yet to be available. Maybe you could add a hint to the docs if it is not yet supported on dart.https://docs.objectbox.io/advanced/entity-inheritance
The text was updated successfully, but these errors were encountered: