robotoworks / mechanoid

Eclipse plugin providing a set of DSL's for the rapid development of Android apps
58 stars 26 forks source link

extend an derived ActiveRecord #242

Closed hannesa2 closed 10 years ago

hannesa2 commented 10 years ago

I try to extend a record and add some non-persistent methods (I know a view is one option, but SQLite doesn't have the android.location.Location and other classes ...)

public class MyExtendedTableRecord extends TableBaseRecord {

    public MyExtendedTableRecord() {
        super();
    }

    public String getTest() {
        return getSomething();
    }

but it's not castable. Is there a way to use it like both access ways

MyExtendedTableRecord extRec = MyExtendedTableRecord.fromCursor(cursor);

List<MyExtendedTableRecord> records = SQuery.newQuery().select(TableBase.CONTENT_URI);

because this is not working

 TableBaseRecord base = TableBaseRecord.fromCursor(cursor);
 MyExtendedTableRecord derived = (MyExtendedTableRecord) base;
fluxtah commented 10 years ago

This is not really possible since record classes are only meant to represent the database row and nothing more.

However you could find where the record is actually created (instantiated) and possibly replace it with your own instantiation of an extended record.