I am trying to the insert a data en my table Tareas. I , m using a ORM (GreenDao).But when run my app, the log cat show that no exist a table named Tareas. I dont understand this because when I have created my database, the Tareas Table has a column named Tipo.
03-30 07:51:32.758 29389-29389/tipiwiny.greendao E/AndroidRuntime: FATAL EXCEPTION: main
Process: tipiwiny.greendao, PID: 29389
android.database.sqlite.SQLiteException: table TAREAS has no column named TIPO (code 1): , while compiling: INSERT INTO TAREAS ('_id','DURACION','TIPO','DESCRIPCION','USUARIO','REALIZADA') VALUES (?,?,?,?,?,?)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:994)
at de.greenrobot.dao.internal.TableStatements.getInsertStatement(TableStatements.java:48)
at de.greenrobot.dao.AbstractDao.insert(AbstractDao.java:293)
at tipiwiny.greendao.CrearTarea.añadirTarea(CrearTarea.java:60)
at tipiwiny.greendao.CrearTarea.access$000(CrearTarea.java:18)
at tipiwiny.greendao.CrearTarea$1.onClick(CrearTarea.java:42)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
My database is defined how:
private static void createDatabase(Schema schema) {
Entity usuario = schema.addEntity("Usuario");
usuario.addIdProperty();
usuario.addStringProperty("nombre").notNull();
usuario.addStringProperty("apellidos").notNull();
usuario.addStringProperty("password").notNull();
usuario.addStringProperty("roll").notNull();
Entity habilidad = schema.addEntity("Habilidad");
habilidad.addIdProperty();
Property usuarioIdProperty = habilidad.addLongProperty("usuarioId").notNull().getProperty();
habilidad.addToOne(usuario, usuarioIdProperty);
habilidad.addIntProperty("tipo").notNull();
Entity tarea=schema.addEntity("Tareas");
tarea.addIdProperty();
tarea.addIntProperty("duracion").notNull();
tarea.addIntProperty("tipo").notNull();
tarea.addStringProperty("descripcion").notNull();
tarea.addStringProperty("usuario");
tarea.addBooleanProperty("realizada");
}
When you execute this code to generate the tables, the class TareasDao is created and the method createTable is:
/** Creates the underlying database table. */
public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "'TAREAS' (" + //
"'_id' INTEGER PRIMARY KEY ," + // 0: id
"'DURACION' INTEGER NOT NULL ," + // 1: duracion
"'TIPO' INTEGER NOT NULL ," + // 2: tipo
"'DESCRIPCION' TEXT NOT NULL ," + // 3: descripcion
"'USUARIO' TEXT," + // 4: usuario
"'REALIZADA' INTEGER);"); // 5: realizada
}
Aucun commentaire:
Enregistrer un commentaire