roscopeco/ormdroid

Man extends Person

Closed this issue · 2 comments

To test your library, I made a simple test :
I created a class Man extends Person extends Entity.
When I try to load all Person in DB, only the Person table is loaded. I was expecting that Man table would also be returned.

Entity.query(Person.class).executeMulti();

Am I doing something wrong ?

Not sure if it is a bug, but an enhancement :D

From that, awesome job guys !

Currently, ORMDroid does not support inheritance in that way - and I feel that to do so would complicate (and bloat) the library. It's primary purpose is to persist simple POJOs, and not deep inheritance hierarchies. It does support inherited classes, but because it uses a "table per concrete class" database model it's not simple (and I suspect not efficient) to implement the functionality you were expecting in this case.

I have some planned changes (for post-1.0) that might allow you to implement this yourself, outside the core library. In the meantime, if you put together some code to implement this kind of behavior I'd love to see it, and maybe make it part of an "optional extras" library...

(Caveat: In the current release, inheritance is completely broken anyway (see bug #13). This is fixed in master and will be tagged for release soon).