Here iam Facing problem using GreenDao ,at the time of Updating the Data in my database:
Here my Dao class looks like this:
package com.dharani.android.legalplex.DataLayer.HoursNotes;
import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import com.dharani.android.legalplex.DataLayer.DaoSession;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.DaoConfig;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.Query;
import de.greenrobot.dao.QueryBuilder;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table tblHoursNotes (schema version 3).
*/
public class clsHoursNotesDao extends AbstractDao<clsHoursNotes, Void> {
public static final String TABLENAME = "tblHoursNotes";
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property HoursNoteID = new Property(1, Integer.class, "hoursNoteID", false, "HOURS_NOTE_ID");
public final static Property HoursSpentSLNO = new Property(2, long.class, "hoursSpentSLNO", false, "HOURS_SPENT_SLNO");
public final static Property NotesHourSpentID = new Property(3, long.class, "notesHourSpentID", false, "NOTES_HOUR_SPENT_ID");
public final static Property HoursNote = new Property(4, String.class, "hoursNote", false, "HOURS_NOTE");
public final static Property HoursNoteAddedByEmployeeID = new Property(5, Integer.class, "hoursNoteAddedByEmployeeID", false, "HOURS_NOTE_ADDED_BY_EMPLOYEE_ID");
public final static Property HoursNoteAddedTimestamp = new Property(6, java.util.Date.class, "hoursNoteAddedTimestamp", false, "HOURS_NOTE_ADDED_TIMESTAMP");
public final static Property HoursNoteUpdateTimestamp = new Property(7, java.util.Date.class, "hoursNoteUpdateTimestamp", false, "HOURS_NOTE_UPDATE_TIMESTAMP");
public final static Property HoursNoteServerUpdateTimestamp = new Property(8, java.util.Date.class, "hoursNoteServerUpdateTimestamp", false, "HOURS_NOTE_SERVER_UPDATE_TIMESTAMP");
public final static Property IsHoursNoteUploadPending = new Property(9, Boolean.class, "isHoursNoteUploadPending", false, "IS_HOURS_NOTE_UPLOAD_PENDING");
};
private Query<clsHoursNotes> clsHoursSpent_HoursNotesSpentValuesQuery;
public clsHoursNotesDao(DaoConfig config) {
super(config);
}
public clsHoursNotesDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
String sql = "CREATE TABLE " + (ifNotExists? "IF NOT EXISTS ": "") + "'tblHoursNotes' (" + //
"'_id' INTEGER PRIMARY KEY ," + // 0: id
"'HOURS_NOTE_ID' INTEGER," + // 1: hoursNoteID
"'HOURS_SPENT_SLNO' INTEGER NOT NULL ," + // 2: hoursNoteCaseSLNO
"'NOTES_HOUR_SPENT_ID' INTEGER NOT NULL ," + // 3: notesHourSpentID
"'HOURS_NOTE' TEXT," + // 4: hoursNote
"'HOURS_NOTE_ADDED_BY_EMPLOYEE_ID' INTEGER," + // 5: hoursNoteAddedByEmployeeID
"'HOURS_NOTE_ADDED_TIMESTAMP' INTEGER," + // 6: hoursNoteAddedTimestamp
"'HOURS_NOTE_UPDATE_TIMESTAMP' INTEGER," + // 7: hoursNoteUpdateTimestamp
"'HOURS_NOTE_SERVER_UPDATE_TIMESTAMP' INTEGER," + // 8: hoursNoteServerUpdateTimestamp
"'IS_HOURS_NOTE_UPLOAD_PENDING' INTEGER);"; // 9: isHoursNoteUploadPending
// Add Indexes
sql += "CREATE INDEX IDX_tblHoursNotes__id ON tblHoursNotes" +
" (_id);";
sql += "CREATE INDEX IDX_tblHoursNotes_HOURS_NOTE_ID ON tblHoursNotes" +
" (HOURS_NOTE_ID);";
sql += "CREATE INDEX IDX_tblHoursNotes_HOURS_NOTE_ADDED_TIMESTAMP ON tblHoursNotes" +
" (HOURS_NOTE_ADDED_TIMESTAMP);";
sql += "CREATE INDEX IDX_tblHoursNotes_HOURS_NOTE_UPDATE_TIMESTAMP ON tblHoursNotes" +
" (HOURS_NOTE_UPDATE_TIMESTAMP);";
sql += "CREATE INDEX IDX_tblHoursNotes_HOURS_NOTE_SERVER_UPDATE_TIMESTAMP ON tblHoursNotes" +
" (HOURS_NOTE_SERVER_UPDATE_TIMESTAMP);";
db.execSQL(sql);
}
/** Drops the underlying database table. */
public static void dropTable(SQLiteDatabase db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'tblHoursNotes'";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, clsHoursNotes entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
if(id!=0) stmt.bindLong(1, id);
}
Integer hoursNoteID = entity.getHoursNoteID();
if (hoursNoteID != null) {
stmt.bindLong(2, hoursNoteID);
}
stmt.bindLong(3, entity.getHoursSpentSLNO());
stmt.bindLong(4, entity.getNotesHourSpentID());
String hoursNote = entity.getHoursNote();
if (hoursNote != null) {
stmt.bindString(5, hoursNote);
}
Integer hoursNoteAddedByEmployeeID = entity.getHoursNoteAddedByEmployeeID();
if (hoursNoteAddedByEmployeeID != null) {
stmt.bindLong(6, hoursNoteAddedByEmployeeID);
}
java.util.Date hoursNoteAddedTimestamp = entity.getHoursNoteAddedTimestamp();
if (hoursNoteAddedTimestamp != null) {
stmt.bindLong(7, hoursNoteAddedTimestamp.getTime());
}
java.util.Date hoursNoteUpdateTimestamp = entity.getHoursNoteUpdateTimestamp();
if (hoursNoteUpdateTimestamp != null) {
stmt.bindLong(8, hoursNoteUpdateTimestamp.getTime());
}
java.util.Date hoursNoteServerUpdateTimestamp = entity.getHoursNoteServerUpdateTimestamp();
if (hoursNoteServerUpdateTimestamp != null) {
stmt.bindLong(9, hoursNoteServerUpdateTimestamp.getTime());
}
Boolean isHoursNoteUploadPending = entity.getIsHoursNoteUploadPending();
if (isHoursNoteUploadPending != null) {
stmt.bindLong(10, isHoursNoteUploadPending ? 1l: 0l);
}
}
/** @inheritdoc */
@Override
public Void readKey(Cursor cursor, int offset) {
return null;
}
/** @inheritdoc */
@Override
public clsHoursNotes readEntity(Cursor cursor, int offset) {
clsHoursNotes entity = new clsHoursNotes( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1), // hoursNoteID
cursor.getLong(offset + 2), // hoursSpentCaseSLNO
cursor.getLong(offset + 3), // notesHourSpentID
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // hoursNote
cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // hoursNoteAddedByEmployeeID
cursor.isNull(offset + 6) ? null : new java.util.Date(cursor.getLong(offset + 6)), // hoursNoteAddedTimestamp
cursor.isNull(offset + 7) ? null : new java.util.Date(cursor.getLong(offset + 7)), // hoursNoteUpdateTimestamp
cursor.isNull(offset + 8) ? null : new java.util.Date(cursor.getLong(offset + 8)), // hoursNoteServerUpdateTimestamp
cursor.isNull(offset + 9) ? null : cursor.getShort(offset + 9) != 0 // isHoursNoteUploadPending
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, clsHoursNotes entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setHoursNoteID(cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1));
entity.setHoursSpentSLNO(cursor.getLong(offset + 2));
entity.setNotesHourSpentID(cursor.getLong(offset + 3));
entity.setHoursNote(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setHoursNoteAddedByEmployeeID(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
entity.setHoursNoteAddedTimestamp(cursor.isNull(offset + 6) ? null : new java.util.Date(cursor.getLong(offset + 6)));
entity.setHoursNoteUpdateTimestamp(cursor.isNull(offset + 7) ? null : new java.util.Date(cursor.getLong(offset + 7)));
entity.setHoursNoteServerUpdateTimestamp(cursor.isNull(offset + 8) ? null : new java.util.Date(cursor.getLong(offset + 8)));
entity.setIsHoursNoteUploadPending(cursor.isNull(offset + 9) ? null : cursor.getShort(offset + 9) != 0);
}
@Override
protected Void updateKeyAfterInsert(clsHoursNotes entity, long rowId) {
// TODO XXX Only Long PKs are supported currently
return null;
}
/** @inheritdoc */
@Override
public Void getKey(clsHoursNotes entity) {
return null;
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
/** Internal query to resolve the "hoursNotesSpentValues" to-many relationship of clsHoursSpent. */
public synchronized List<clsHoursNotes> _queryClsHoursSpent_HoursNotesSpentValues(long notesHourSpentID) {
if (clsHoursSpent_HoursNotesSpentValuesQuery == null) {
QueryBuilder<clsHoursNotes> queryBuilder = queryBuilder();
queryBuilder.where(Properties.HoursSpentSLNO.eq(notesHourSpentID)).orderDesc(Properties.HoursNoteUpdateTimestamp);
clsHoursSpent_HoursNotesSpentValuesQuery = queryBuilder.build();
} else {
clsHoursSpent_HoursNotesSpentValuesQuery.setParameter(0, notesHourSpentID);
}
return clsHoursSpent_HoursNotesSpentValuesQuery.list();
}
}
i fixed the issue by Changing the Return type of AbstractDao class Parmeter from ,after changing my classs looks like this:
package com.dharani.android.legalplex.DataLayer.HoursNotes;
import java.util.List;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import com.dharani.android.legalplex.DataLayer.DaoSession;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.DaoConfig;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.Query;
import de.greenrobot.dao.QueryBuilder;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table tblHoursNotes (schema version 3).
*/
public class clsHoursNotesDao extends AbstractDao<clsHoursNotes, Long> {
public static final String TABLENAME = "tblHoursNotes";
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property HoursNoteID = new Property(1, Integer.class, "hoursNoteID", false, "HOURS_NOTE_ID");
public final static Property HoursSpentSLNO = new Property(2, long.class, "hoursSpentSLNO", false, "HOURS_SPENT_SLNO");
public final static Property NotesHourSpentID = new Property(3, long.class, "notesHourSpentID", false, "NOTES_HOUR_SPENT_ID");
public final static Property HoursNote = new Property(4, String.class, "hoursNote", false, "HOURS_NOTE");
public final static Property HoursNoteAddedByEmployeeID = new Property(5, Integer.class, "hoursNoteAddedByEmployeeID", false, "HOURS_NOTE_ADDED_BY_EMPLOYEE_ID");
public final static Property HoursNoteAddedTimestamp = new Property(6, java.util.Date.class, "hoursNoteAddedTimestamp", false, "HOURS_NOTE_ADDED_TIMESTAMP");
public final static Property HoursNoteUpdateTimestamp = new Property(7, java.util.Date.class, "hoursNoteUpdateTimestamp", false, "HOURS_NOTE_UPDATE_TIMESTAMP");
public final static Property HoursNoteServerUpdateTimestamp = new Property(8, java.util.Date.class, "hoursNoteServerUpdateTimestamp", false, "HOURS_NOTE_SERVER_UPDATE_TIMESTAMP");
public final static Property IsHoursNoteUploadPending = new Property(9, Boolean.class, "isHoursNoteUploadPending", false, "IS_HOURS_NOTE_UPLOAD_PENDING");
};
private DaoSession daoSession;
private Query<clsHoursNotes> clsHoursSpent_HoursNotesSpentValuesQuery;
public clsHoursNotesDao(DaoConfig config) {
super(config);
}
public clsHoursNotesDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
String sql = "CREATE TABLE " + (ifNotExists? "IF NOT EXISTS ": "") + "'tblHoursNotes' (" + //
"'_id' INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"'HOURS_NOTE_ID' INTEGER," + // 1: hoursNoteID
"'HOURS_SPENT_SLNO' INTEGER NOT NULL ," + // 2: hoursNoteCaseSLNO
"'NOTES_HOUR_SPENT_ID' INTEGER NOT NULL ," + // 3: notesHourSpentID
"'HOURS_NOTE' TEXT," + // 4: hoursNote
"'HOURS_NOTE_ADDED_BY_EMPLOYEE_ID' INTEGER," + // 5: hoursNoteAddedByEmployeeID
"'HOURS_NOTE_ADDED_TIMESTAMP' INTEGER," + // 6: hoursNoteAddedTimestamp
"'HOURS_NOTE_UPDATE_TIMESTAMP' INTEGER," + // 7: hoursNoteUpdateTimestamp
"'HOURS_NOTE_SERVER_UPDATE_TIMESTAMP' INTEGER," + // 8: hoursNoteServerUpdateTimestamp
"'IS_HOURS_NOTE_UPLOAD_PENDING' INTEGER);"; // 9: isHoursNoteUploadPending
// Add Indexes
sql += "CREATE INDEX IDX_tblHoursNotes__id ON tblHoursNotes" +
" (_id);";
sql += "CREATE INDEX IDX_tblHoursNotes_HOURS_NOTE_ID ON tblHoursNotes" +
" (HOURS_NOTE_ID);";
sql += "CREATE INDEX IDX_tblHoursNotes_HOURS_NOTE_ADDED_TIMESTAMP ON tblHoursNotes" +
" (HOURS_NOTE_ADDED_TIMESTAMP);";
sql += "CREATE INDEX IDX_tblHoursNotes_HOURS_NOTE_UPDATE_TIMESTAMP ON tblHoursNotes" +
" (HOURS_NOTE_UPDATE_TIMESTAMP);";
sql += "CREATE INDEX IDX_tblHoursNotes_HOURS_NOTE_SERVER_UPDATE_TIMESTAMP ON tblHoursNotes" +
" (HOURS_NOTE_SERVER_UPDATE_TIMESTAMP);";
db.execSQL(sql);
}
/** Drops the underlying database table. */
public static void dropTable(SQLiteDatabase db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'tblHoursNotes'";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, clsHoursNotes entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
if(id!=0) stmt.bindLong(1, id);
}
Integer hoursNoteID = entity.getHoursNoteID();
if (hoursNoteID != null) {
stmt.bindLong(2, hoursNoteID);
}
stmt.bindLong(3, entity.getHoursSpentSLNO());
stmt.bindLong(4, entity.getNotesHourSpentID());
String hoursNote = entity.getHoursNote();
if (hoursNote != null) {
stmt.bindString(5, hoursNote);
}
Integer hoursNoteAddedByEmployeeID = entity.getHoursNoteAddedByEmployeeID();
if (hoursNoteAddedByEmployeeID != null) {
stmt.bindLong(6, hoursNoteAddedByEmployeeID);
}
java.util.Date hoursNoteAddedTimestamp = entity.getHoursNoteAddedTimestamp();
if (hoursNoteAddedTimestamp != null) {
stmt.bindLong(7, hoursNoteAddedTimestamp.getTime());
}
java.util.Date hoursNoteUpdateTimestamp = entity.getHoursNoteUpdateTimestamp();
if (hoursNoteUpdateTimestamp != null) {
stmt.bindLong(8, hoursNoteUpdateTimestamp.getTime());
}
java.util.Date hoursNoteServerUpdateTimestamp = entity.getHoursNoteServerUpdateTimestamp();
if (hoursNoteServerUpdateTimestamp != null) {
stmt.bindLong(9, hoursNoteServerUpdateTimestamp.getTime());
}
Boolean isHoursNoteUploadPending = entity.getIsHoursNoteUploadPending();
if (isHoursNoteUploadPending != null) {
stmt.bindLong(10, isHoursNoteUploadPending ? 1l: 0l);
}
}
/** @inheritdoc */
@Override
public Long readKey(Cursor cursor, int offset) {
// return null;
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
/** @inheritdoc */
@Override
public clsHoursNotes readEntity(Cursor cursor, int offset) {
clsHoursNotes entity = new clsHoursNotes( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1), // hoursNoteID
cursor.getLong(offset + 2), // hoursSpentCaseSLNO
cursor.getLong(offset + 3), // notesHourSpentID
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // hoursNote
cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // hoursNoteAddedByEmployeeID
cursor.isNull(offset + 6) ? null : new java.util.Date(cursor.getLong(offset + 6)), // hoursNoteAddedTimestamp
cursor.isNull(offset + 7) ? null : new java.util.Date(cursor.getLong(offset + 7)), // hoursNoteUpdateTimestamp
cursor.isNull(offset + 8) ? null : new java.util.Date(cursor.getLong(offset + 8)), // hoursNoteServerUpdateTimestamp
cursor.isNull(offset + 9) ? null : cursor.getShort(offset + 9) != 0 // isHoursNoteUploadPending
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, clsHoursNotes entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setHoursNoteID(cursor.isNull(offset + 1) ? null : cursor.getInt(offset + 1));
entity.setHoursSpentSLNO(cursor.getLong(offset + 2));
entity.setNotesHourSpentID(cursor.getLong(offset + 3));
entity.setHoursNote(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setHoursNoteAddedByEmployeeID(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
entity.setHoursNoteAddedTimestamp(cursor.isNull(offset + 6) ? null : new java.util.Date(cursor.getLong(offset + 6)));
entity.setHoursNoteUpdateTimestamp(cursor.isNull(offset + 7) ? null : new java.util.Date(cursor.getLong(offset + 7)));
entity.setHoursNoteServerUpdateTimestamp(cursor.isNull(offset + 8) ? null : new java.util.Date(cursor.getLong(offset + 8)));
entity.setIsHoursNoteUploadPending(cursor.isNull(offset + 9) ? null : cursor.getShort(offset + 9) != 0);
}
@Override
protected Long updateKeyAfterInsert(clsHoursNotes entity, long rowId) {
// TODO XXX Only Long PKs are supported currently
//return null;
entity.setId(rowId);
return rowId;
}
/** @inheritdoc */
@Override
public Long getKey(clsHoursNotes entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
//return null;
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
/** Internal query to resolve the "hoursNotesSpentValues" to-many relationship of clsHoursSpent. */
public synchronized List<clsHoursNotes> _queryClsHoursSpent_HoursNotesSpentValues(long notesHourSpentID) {
if (clsHoursSpent_HoursNotesSpentValuesQuery == null) {
QueryBuilder<clsHoursNotes> queryBuilder = queryBuilder();
queryBuilder.where(Properties.HoursSpentSLNO.eq(notesHourSpentID)).orderDesc(Properties.HoursNoteUpdateTimestamp);
clsHoursSpent_HoursNotesSpentValuesQuery = queryBuilder.build();
} else {
clsHoursSpent_HoursNotesSpentValuesQuery.setParameter(0, notesHourSpentID);
}
return clsHoursSpent_HoursNotesSpentValuesQuery.list();
}
}
Comments
Post a Comment