Android Room with entity inheritance

Viewed 793

I have a room database with a entity with some subclass.

Each subclass, has some methods overrides and I need get that overrided methods when I use the entities.

Any way to get all entities and each as correct subclass implementations?

Example:

base class -> Person

sublcass1 -> Teacher

sublcass2 -> Student

And when get all persons, any each is a diferents class (some are Student, some are Teacher...)

var persons = getAllPersons();

if (person[0] as Student)

....

if (person[1] as Teacher)

...

0 Answers
Related