I am trying to establish a relation between objects like the one below. After adding different Order objects to mainCourses and dessert, when loading the Customer object, both mainCourses and dessert lists have the same values.
@Entity()
class Customer {
int id = 0;
@Backlink('customer')
final mainCourses = ToMany<Order>();
@Backlink('customer')
final dessert = ToMany<Order>();
}
@Entity()
class Order {
int id = 0;
final customer = ToOne<Customer>();
}
I expected that each ToMany relation could contain its own list of Order objects
The
ToMany
relations are set up as@Backlink
to the samecustomer
ToOne
relation inOrder
. Backlink relations do not really exist, they are based on another relation.You could create another
ToOne
inOrder
just for desserts:Or create an actual
ToMany
relation for each: