Android Open Source - android-orm-benchmark Message Dao






From Project

Back to project page android-orm-benchmark.

License

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.

Java Source Code

package com.littleinc.orm_benchmark.greendao;
// w  ww.ja va  2 s.  com
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 com.littleinc.orm_benchmark.greendao.Message;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table MESSAGE.
*/
public class MessageDao extends AbstractDao<Message, Long> {

    public static final String TABLENAME = "MESSAGE";

    /**
     * Properties of entity Message.<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 Content = new Property(1, String.class, "content", false, "CONTENT");
        public final static Property Client_id = new Property(2, Long.class, "client_id", false, "CLIENT_ID");
        public final static Property Created_at = new Property(3, Integer.class, "created_at", false, "CREATED_AT");
        public final static Property Sorted_by = new Property(4, Double.class, "sorted_by", false, "SORTED_BY");
        public final static Property Command_id = new Property(5, Long.class, "command_id", false, "COMMAND_ID");
        public final static Property Sender_id = new Property(6, long.class, "sender_id", false, "SENDER_ID");
        public final static Property Channel_id = new Property(7, long.class, "channel_id", false, "CHANNEL_ID");
    };

    private DaoSession daoSession;


    public MessageDao(DaoConfig config) {
        super(config);
    }
    
    public MessageDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
        this.daoSession = 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 + "'MESSAGE' (" + //
                "'_id' INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "'CONTENT' TEXT," + // 1: content
                "'CLIENT_ID' INTEGER," + // 2: client_id
                "'CREATED_AT' INTEGER," + // 3: created_at
                "'SORTED_BY' REAL," + // 4: sorted_by
                "'COMMAND_ID' INTEGER," + // 5: command_id
                "'SENDER_ID' INTEGER NOT NULL ," + // 6: sender_id
                "'CHANNEL_ID' INTEGER NOT NULL );"); // 7: channel_id
        // Add Indexes
        db.execSQL("CREATE INDEX " + constraint + "IDX_MESSAGE_COMMAND_ID ON MESSAGE" +
                " (COMMAND_ID);");
    }

    /** Drops the underlying database table. */
    public static void dropTable(SQLiteDatabase db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "'MESSAGE'";
        db.execSQL(sql);
    }

    /** @inheritdoc */
    @Override
    protected void bindValues(SQLiteStatement stmt, Message entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(2, content);
        }
 
        Long client_id = entity.getClient_id();
        if (client_id != null) {
            stmt.bindLong(3, client_id);
        }
 
        Integer created_at = entity.getCreated_at();
        if (created_at != null) {
            stmt.bindLong(4, created_at);
        }
 
        Double sorted_by = entity.getSorted_by();
        if (sorted_by != null) {
            stmt.bindDouble(5, sorted_by);
        }
 
        Long command_id = entity.getCommand_id();
        if (command_id != null) {
            stmt.bindLong(6, command_id);
        }
        stmt.bindLong(7, entity.getSender_id());
        stmt.bindLong(8, entity.getChannel_id());
    }

    @Override
    protected void attachEntity(Message entity) {
        super.attachEntity(entity);
        entity.__setDaoSession(daoSession);
    }

    /** @inheritdoc */
    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    /** @inheritdoc */
    @Override
    public Message readEntity(Cursor cursor, int offset) {
        Message entity = new Message( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // content
            cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // client_id
            cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3), // created_at
            cursor.isNull(offset + 4) ? null : cursor.getDouble(offset + 4), // sorted_by
            cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5), // command_id
            cursor.getLong(offset + 6), // sender_id
            cursor.getLong(offset + 7) // channel_id
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, Message entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setContent(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setClient_id(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2));
        entity.setCreated_at(cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3));
        entity.setSorted_by(cursor.isNull(offset + 4) ? null : cursor.getDouble(offset + 4));
        entity.setCommand_id(cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5));
        entity.setSender_id(cursor.getLong(offset + 6));
        entity.setChannel_id(cursor.getLong(offset + 7));
     }
    
    /** @inheritdoc */
    @Override
    protected Long updateKeyAfterInsert(Message entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    /** @inheritdoc */
    @Override
    public Long getKey(Message entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    /** @inheritdoc */
    @Override    
    protected boolean isEntityUpdateable() {
        return true;
    }
    
}




Java Source Code List

com.littleinc.orm_benchmark.Application.java
com.littleinc.orm_benchmark.BenchmarkExecutable.java
com.littleinc.orm_benchmark.MainActivity.java
com.littleinc.orm_benchmark.greendao.DaoMaster.java
com.littleinc.orm_benchmark.greendao.DaoSession.java
com.littleinc.orm_benchmark.greendao.DataBaseHelper.java
com.littleinc.orm_benchmark.greendao.Generator.java
com.littleinc.orm_benchmark.greendao.GreenDaoExecutor.java
com.littleinc.orm_benchmark.greendao.MessageDao.java
com.littleinc.orm_benchmark.greendao.Message.java
com.littleinc.orm_benchmark.greendao.UserDao.java
com.littleinc.orm_benchmark.greendao.User.java
com.littleinc.orm_benchmark.ormlite.Contact.java
com.littleinc.orm_benchmark.ormlite.DataBaseHelper.java
com.littleinc.orm_benchmark.ormlite.Message.java
com.littleinc.orm_benchmark.ormlite.ORMLiteExecutor.java
com.littleinc.orm_benchmark.ormlite.User.java
com.littleinc.orm_benchmark.ormlite.config.DBConfigUtil.java
com.littleinc.orm_benchmark.sqlite.DataBaseHelper.java
com.littleinc.orm_benchmark.sqlite.Message.java
com.littleinc.orm_benchmark.sqlite.SQLiteExecutor.java
com.littleinc.orm_benchmark.sqlite.User.java
com.littleinc.orm_benchmark.util.Util.java