/** @inheritdoc */ @Override protected void bindValues(SQLiteStatement stmt, Person entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } stmt.bindString(2, entity.getName()); Integer age = entity.getAge(); if (age != null) { stmt.bindLong(3, age); } Integer height = entity.getHeight(); if (height != null) { stmt.bindLong(4, height); } String introduction = entity.getIntroduction(); if (introduction != null) { stmt.bindString(5, introduction); } }
/** @inheritdoc */ @Override public void readEntity(Cursor cursor, Person entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); entity.setName(cursor.getString(offset + 1)); entity.setAge(cursor.isNull(offset + 2) ? null : cursor.getInt(offset + 2)); entity.setHeight(cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3)); entity.setIntroduction(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4)); }
/** @inheritdoc */ @Override public Long getKey(Person entity) { if (entity != null) { return entity.getId(); } else { return null; } }
/** @inheritdoc */ @Override protected Long updateKeyAfterInsert(Person entity, long rowId) { entity.setId(rowId); return rowId; }