Back to project page android-orm-benchmark.
The source code is released under:
Apache License
If you think the Android project android-orm-benchmark listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.littleinc.orm_benchmark.greendao; /*from w ww.ja v a2 s . c o m*/ import java.util.List; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; import de.greenrobot.dao.AbstractDao; import de.greenrobot.dao.Property; import de.greenrobot.dao.internal.DaoConfig; import de.greenrobot.dao.query.Query; import de.greenrobot.dao.query.QueryBuilder; import com.littleinc.orm_benchmark.greendao.User; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. /** * DAO for table USER. */ public class UserDao extends AbstractDao<User, Long> { public static final String TABLENAME = "USER"; /** * Properties of entity User.<br/> * Can be used for QueryBuilder and for referencing column names. */ public static class Properties { public final static Property Last_name = new Property(0, String.class, "last_name", false, "LAST_NAME"); public final static Property First_name = new Property(1, String.class, "first_name", false, "FIRST_NAME"); public final static Property Id = new Property(2, Long.class, "id", true, "_id"); }; private Query<User> message_ReadersQuery; public UserDao(DaoConfig config) { super(config); } public UserDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } /** Creates the underlying database table. */ public static void createTable(SQLiteDatabase db, boolean ifNotExists) { String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "'USER' (" + // "'LAST_NAME' TEXT," + // 0: last_name "'FIRST_NAME' TEXT," + // 1: first_name "'_id' INTEGER PRIMARY KEY AUTOINCREMENT );"); // 2: id } /** Drops the underlying database table. */ public static void dropTable(SQLiteDatabase db, boolean ifExists) { String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'USER'"; db.execSQL(sql); } /** @inheritdoc */ @Override protected void bindValues(SQLiteStatement stmt, User entity) { stmt.clearBindings(); String last_name = entity.getLast_name(); if (last_name != null) { stmt.bindString(1, last_name); } String first_name = entity.getFirst_name(); if (first_name != null) { stmt.bindString(2, first_name); } Long id = entity.getId(); if (id != null) { stmt.bindLong(3, id); } } /** @inheritdoc */ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2); } /** @inheritdoc */ @Override public User readEntity(Cursor cursor, int offset) { User entity = new User( // cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // last_name cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // first_name cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2) // id ); return entity; } /** @inheritdoc */ @Override public void readEntity(Cursor cursor, User entity, int offset) { entity.setLast_name(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0)); entity.setFirst_name(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1)); entity.setId(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2)); } /** @inheritdoc */ @Override protected Long updateKeyAfterInsert(User entity, long rowId) { entity.setId(rowId); return rowId; } /** @inheritdoc */ @Override public Long getKey(User entity) { if(entity != null) { return entity.getId(); } else { return null; } } /** @inheritdoc */ @Override protected boolean isEntityUpdateable() { return true; } /** Internal query to resolve the "readers" to-many relationship of Message. */ public List<User> _queryMessage_Readers(Long id) { synchronized (this) { if (message_ReadersQuery == null) { QueryBuilder<User> queryBuilder = queryBuilder(); queryBuilder.where(Properties.Id.eq(null)); message_ReadersQuery = queryBuilder.build(); } } Query<User> query = message_ReadersQuery.forCurrentThread(); query.setParameter(0, id); return query.list(); } }