agrosner / DBFlow

A blazing fast, powerful, and very simple ORM android database library that writes database code for you.
MIT License
4.87k stars 598 forks source link

Table is not registered with a Database. Did you forget an annotation? #1683

Closed muhammadzadeh closed 5 years ago

muhammadzadeh commented 5 years ago

DBFlow Version:4.2.4

Bug : com.raizlabs.android.dbflow.structure.InvalidDBConfiguration Table is not registered with a Database. Did you forget an annotation?

Description: my project contain git submodules, each submodule is a complete module with its database. now when i want to use them in main app , its crash

Caused by: com.raizlabs.android.dbflow.structure.InvalidDBConfiguration: Model object: c.data.database.SubscribeTopicTable is not registered with a Database. Did you forget an annotation?

@Table(database = PaModuleDatabase.class)
public class SubscribeTopicTable extends BaseModel {

@Column
@PrimaryKey
public String topic;

@Column(defaultValue = "")
public String where;

@Column(defaultValue = "")
public String when;

@Column(defaultValue = "")
public String extra;

}

submodule database @Database(name = PaModuleDatabase.NAME, version = PassengerModuleDatabase.VERSION) public class PassengerModuleDatabase { public static final String NAME="pa_module"; public static final int VERSION = 1; }

Application class of main app ` @Override public void onCreate() { super.onCreate();

    FlowConfig.Builder databasesBuilder = new FlowConfig.Builder(this);

    databasesBuilder.addDatabaseConfig(
            new DatabaseConfig
                    .Builder(AppDatabase.class)
                    .openHelper(new DatabaseConfig.OpenHelperCreator() {
                        @Override
                        public OpenHelper createHelper(DatabaseDefinition databaseDefinition, DatabaseHelperListener helperListener) {
                            return new SQLCipherHelperImpl(databaseDefinition, helperListener, getApplicationContext());
                        }
                    })
                    .build());

    for (Modules m: i < Modules.getList()){

        databasesBuilder.addDatabaseConfig(
                new DatabaseConfig
                        .Builder(m.getDatabase())
                        .openHelper(new DatabaseConfig.OpenHelperCreator() {
                            @Override
                            public OpenHelper createHelper(DatabaseDefinition databaseDefinition, DatabaseHelperListener helperListener) {
                                return new SQLCipherHelperImpl(databaseDefinition, helperListener, getApplicationContext());
                            }
                        })
                        .build());
    }

    FlowManager.init(databasesBuilder.build());

}

`