Wackymax/CPOrm

cporm doent make tables

Closed this issue · 5 comments

i mase a simple model and corm made db but there is no any table except metatable
i got npe logs because there is no table in it

 FATAL EXCEPTION: main
                                                                        java.lang.RuntimeException: Unable to create application ir.plusteam.zekrekheyr.Application.Application: java.lang.NullPointerException
                                                                            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4704)
                                                                            at android.app.ActivityThread.access$1300(ActivityThread.java:171)
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1453)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                            at android.os.Looper.loop(Looper.java:194)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5468)
                                                                            at java.lang.reflect.Method.invokeNative(Native Method)
                                                                            at java.lang.reflect.Method.invoke(Method.java:525)
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:936)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
                                                                            at dalvik.system.NativeStart.main(Native Method)
                                                                         Caused by: java.lang.NullPointerException
                                                                            at android.os.Parcel.readException(Parcel.java:1434)
                                                                            at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:185)
                                                                            at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:137)
                                                                            at android.content.ContentProviderProxy.insert(ContentProviderNative.java:433)
                                                                            at android.content.ContentResolver.insert(ContentResolver.java:917)
                                                                            at za.co.cporm.model.CPOrm.insert(CPOrm.java:151)
                                                                            at za.co.cporm.model.CPOrm.insert(CPOrm.java:141)
                                                                            at ir.plusteam.zekrekheyr.Application.Application.onCreate(Application.java:63)
                                                                            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1070)
                                                                            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4701)
                                                                            at android.app.ActivityThread.access$1300(ActivityThread.java:171) 
                                                                            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1453) 
                                                                            at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                            at android.os.Looper.loop(Looper.java:194) 
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5468) 
                                                                            at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                            at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:936) 
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703) 
                                                                            at dalvik.system.NativeStart.main(Native Method) 

this is my model

@Table(tableName = "mytable")
public class MuModel   {

    @Column
    @PrimaryKey(autoIncrement = true)
    public long pId;

    @Column(columnName = "title")
    public long title;

}

Hi yeganehaym,

Please ensure that your model is registered in the database configuration and that the database configuration is registered in the manifest. You can also maybe check that your authority in the provider matches the authority for CPOrm registered in the manifest file.

package ir.plusteam.zekrekheyr.BackupHelper.Configs;


import java.util.ArrayList;
import java.util.List;

import ir.plusteam.zekrekheyr.MuModel;
import za.co.cporm.model.CPOrmConfiguration;

public class BackupConfig implements CPOrmConfiguration {

    @Override
    public String getDatabaseName() {

        return "backup.db";
    }

    @Override
    public int getDatabaseVersion() {

        return 1;
    }

    @Override
    public boolean isQueryLoggingEnabled() {

        return false;
    }

    @Override
    public String upgradeResourceDirectory() {
        return null;
    }

    @Override
    public List<Class<?>> getDataModelObjects() {
        List<Class<?>> domainObjects = new ArrayList<Class<?>>();
       domainObjects.add(MuModel.class);



        return domainObjects;
    }
}


   <meta-data
            android:name="CPORM_CONFIG"
            android:value="ir.plusteam.zekrekheyr.BackupHelper.Configs.BackupConfig"/>
        <!-- This is optional -->
        <meta-data
            android:name="AUTHORITY"
            android:value="ir.plusteam"/>
        <!-- providers -->
        <provider
            android:name="za.co.cporm.provider.CPOrmContentProvider"
            android:authorities="ir.plusteam"
            android:exported="false"
            android:process=":provider"/>

Hi,

It seems like you are making changes to an existing database. If you increase the version number for the database it should recreate it with the new tables.

hi again
this is first time i'm making db
i mean db created but my table is not created just android_metadata table
however i increased version from1 to 2 but nothing happend

Hi yeganehaym,

Can you enable query logging in the database config and see what the results are in the logs? It might provide us with some more information.