Android Open Source - android-orm-benchmark Generator






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;
/*from   w ww. jav a  2s.  c  om*/
import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;

public class Generator {

    // DB CONFIG
    private static int DB_VERSION = 2;

    private static String PACKAGE = "com.littleinc.orm_benchmark.greendao";

    // USER TABLE
    private static final String USER_ENTITY = "User";

    public static final String LAST_NAME_COLUMN = "last_name";

    public static final String FIRST_NAME_COLUMN = "first_name";

    // MESSAGE TABLE
    private static final String MESSAGE_ENTITY = "Message";

    private static final String CONTENT = "content";

    private static final String READERS = "readers";

    private static final String SORTED_BY = "sorted_by";

    private static final String CLIENT_ID = "client_id";

    private static final String SENDER_ID = "sender_id";

    private static final String CHANNEL_ID = "channel_id";

    private static final String COMMAND_ID = "command_id";

    private static final String CREATED_AT = "created_at";

    public static void main(String[] args) {
        Schema schema = new Schema(DB_VERSION, PACKAGE);

        Entity user = schema.addEntity(USER_ENTITY);
        Property userPk = addCommonColumns(user);

        Entity message = schema.addEntity(MESSAGE_ENTITY);
        message.addIdProperty().autoincrement();
        message.addStringProperty(CONTENT);
        message.addLongProperty(CLIENT_ID);
        message.addIntProperty(CREATED_AT);
        message.addDoubleProperty(SORTED_BY);
        message.addLongProperty(COMMAND_ID).index();
        message.addLongProperty(SENDER_ID).notNull();
        message.addLongProperty(CHANNEL_ID).notNull();

        // One-to-many relationship
        message.addToMany(user, userPk, READERS);

        try {
            new DaoGenerator().generateAll(schema, "../ORM-Benchmark/src/");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static Property addCommonColumns(Entity entity) {
        entity.addStringProperty(LAST_NAME_COLUMN);
        entity.addStringProperty(FIRST_NAME_COLUMN);
        return entity.addIdProperty().autoincrement().getProperty();
    }
}




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