Open obrunsmann opened 2 years ago
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
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?
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
abstract class Shape {}
class Circle implements Shape {
int id = 0;
int? radius;
}
class Square implements Shape {
int id = 0;
int? side;
}
class ShapeModel {
int id = 0;
final shape = ToOne<Shape>();
}
basically in my case the nested child in json structure has different key value pairs and I cannot save it as Map
I would need this feature too
I also need this feature to be able to implement common fields on multiple entities
I also need this to be able to reuse code
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...
hello, i want this feature
This would be great to have
This is a huge limitation for me, it will be great to have it specially due to the fact that it's available in the other platforms versions.
Here the same
I also would be very happy once this feature gets released! 🚀
Is there any plan to implement it? :)
still not a resolution for dart?
There have been a lot of comments here. The "needs more interest" label should be removed
Exactly, how come 'needs more interest'? inheritance its an essential and crucial thing, it should be already included!!! Please
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 :
Better a late answer then none :) @LeoK987
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?
Yes, that's what happens. You can see it in action here: https://github.com/objectbox/objectbox-dart-performance/blob/main/lib/model.dart
Please consider implementing this feature, otherwise using workarounds or not using inheritance for objectbox entities is prevents creating good structured models.
It really sad to give up of a good database because one of the good feature for OOP is not implemented.
Waiting eagerly for this feature! Hereby showing my interest here
If you are interested in this please thumbs up the original post, this helps us track interest!
Is there any plan to implement it? :)
why not support this feature? It is so important
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 :+1: at the issue description at the top :arrow_up:. 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