package com.adm.dictionary.dao; import java.util.List; import android.database.Cursor; import android.database.sqlite.SQLiteStatement; import org.greenrobot.greendao.AbstractDao; import org.greenrobot.greendao.Property; import org.greenrobot.greendao.internal.DaoConfig; import org.greenrobot.greendao.database.Database; import org.greenrobot.greendao.database.DatabaseStatement; import org.greenrobot.greendao.query.Query; import org.greenrobot.greendao.query.QueryBuilder; import com.adm.dictionary.bean.Part; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. /** * DAO for table "PART". */ public class PartDao extends AbstractDao<Part, Long> { public static final String TABLENAME = "PART"; /** * Properties of entity Part.<br/> * Can be used for QueryBuilder and for referencing column names. */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); public final static Property WordId = new Property(1, Long.class, "wordId", false, "WORD_ID"); public final static Property Part = new Property(2, String.class, "part", false, "PART"); public final static Property Means = new Property(3, String.class, "means", false, "MEANS"); } private Query<Part> wordBean_PartsQuery; public PartDao(DaoConfig config) { super(config); } public PartDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } /** Creates the underlying database table. */ public static void createTable(Database db, boolean ifNotExists) { String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"PART\" (" + // "\"_id\" INTEGER PRIMARY KEY ," + // 0: id "\"WORD_ID\" INTEGER," + // 1: wordId "\"PART\" TEXT," + // 2: part "\"MEANS\" TEXT);"); // 3: means } /** Drops the underlying database table. */ public static void dropTable(Database db, boolean ifExists) { String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"PART\""; db.execSQL(sql); } @Override protected final void bindValues(DatabaseStatement stmt, Part entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } Long wordId = entity.getWordId(); if (wordId != null) { stmt.bindLong(2, wordId); } String part = entity.getPart(); if (part != null) { stmt.bindString(3, part); } String means = entity.getMeans(); if (means != null) { stmt.bindString(4, means); } } @Override protected final void bindValues(SQLiteStatement stmt, Part entity) { stmt.clearBindings(); Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } Long wordId = entity.getWordId(); if (wordId != null) { stmt.bindLong(2, wordId); } String part = entity.getPart(); if (part != null) { stmt.bindString(3, part); } String means = entity.getMeans(); if (means != null) { stmt.bindString(4, means); } } @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); } @Override public Part readEntity(Cursor cursor, int offset) { Part entity = new Part( // cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // wordId cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // part cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3) // means ); return entity; } @Override public void readEntity(Cursor cursor, Part entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); entity.setWordId(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1)); entity.setPart(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2)); entity.setMeans(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3)); } @Override protected final Long updateKeyAfterInsert(Part entity, long rowId) { entity.setId(rowId); return rowId; } @Override public Long getKey(Part entity) { if(entity != null) { return entity.getId(); } else { return null; } } @Override public boolean hasKey(Part entity) { return entity.getId() != null; } @Override protected final boolean isEntityUpdateable() { return true; } /** Internal query to resolve the "parts" to-many relationship of WordBean. */ public List<Part> _queryWordBean_Parts(Long wordId) { synchronized (this) { if (wordBean_PartsQuery == null) { QueryBuilder<Part> queryBuilder = queryBuilder(); queryBuilder.where(Properties.WordId.eq(null)); wordBean_PartsQuery = queryBuilder.build(); } } Query<Part> query = wordBean_PartsQuery.forCurrentThread(); query.setParameter(0, wordId); return query.list(); } }