Java Code Examples for de.greenrobot.daogenerator.Schema#addEntity()

The following examples show how to use de.greenrobot.daogenerator.Schema#addEntity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MyGreenDAOGenerator.java    From Maps with GNU General Public License v2.0 6 votes vote down vote up
private static void addCameraTable(Schema schema) {
    // 一个实体(类)就关联到数据库中的一张表,此处表名为「Note」(既类名)
    Entity camera = schema.addEntity("BJCamera");
    // 你也可以重新给表命名
    // note.setTableName("NODE");

    // greenDAO 会自动根据实体类的属性值来创建表字段,并赋予默认值
    // 接下来你便可以设置表中的字段:
    // 与在 Java 中使用驼峰命名法不同,默认数据库中的命名是使用大写和下划线来分割单词的。
    // For example, a property called “creationDate” will become a database column “CREATION_DATE”.
    camera.addIdProperty().autoincrement();
    camera.addStringProperty("name").notNull();
    camera.addStringProperty("address");
    camera.addDoubleProperty("latitude");
    camera.addDoubleProperty("longtitude");
    camera.addStringProperty("direction");
}
 
Example 2
Source File: HttpCookieDaoGenerator.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
private static void addHttpCookie(Schema schema) {
    Entity entity = schema.addEntity("HttpCookieRaw");
    entity.setTableName("HTTP_COOKIE");
    entity.setClassNameDao("HttpCookieDao");
    entity.addIdProperty();
    entity.addStringProperty("name");
    entity.addStringProperty("value");
    entity.addStringProperty("comment");
    entity.addStringProperty("commentURL");
    entity.addBooleanProperty("discard");
    entity.addStringProperty("domain");
    entity.addLongProperty("maxAge");
    entity.addStringProperty("path");
    entity.addStringProperty("portList");
    entity.addBooleanProperty("secure");
    entity.addIntProperty("version");
    entity.addStringProperty("url");
    entity.addLongProperty("whenCreated");
}
 
Example 3
Source File: GreenDaoGen.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
private static void addAccountTable(Schema schema) {

        Entity table = schema.addEntity("Green_AccountBean");
        table.setHasKeepSections(true);
        table.setTableName(AccountTable.ACCOUNT_TABLE);
        table.implementsSerializable();

        table.addLongProperty(AccountTable.UID).primaryKey();
        table.addStringProperty(AccountTable.USER_NAME);
        table.addStringProperty(AccountTable.USER_PWD);
        table.addStringProperty(AccountTable.COOKIE);
        table.addStringProperty(AccountTable.OAUTH_TOKEN);
        table.addLongProperty(AccountTable.OAUTH_TOKEN_EXPIRES_TIME);
        table.addStringProperty(AccountTable.ACCESS_TOKEN_HACK);
        table.addLongProperty(AccountTable.ACCESS_TOKEN_HACK_EXPIRES_TIME);
        table.addStringProperty(AccountTable.G_SID);
        table.addIntProperty(AccountTable.NAVIGATION_POSITION);
        table.addStringProperty(AccountTable.USER_INFO_JSON);
    }
 
Example 4
Source File: GreenDaoGenerator.java    From sctalk with Apache License 2.0 6 votes vote down vote up
private static void addSessionInfo(Schema schema){
    Entity sessionInfo = schema.addEntity("SessionEntity");
    sessionInfo.setTableName("Session");
    sessionInfo.setClassNameDao("SessionDao");
    sessionInfo.setJavaPackage(entityPath);

    //point to userId/groupId need sessionType 区分
    sessionInfo.addIdProperty().autoincrement();
    sessionInfo.addStringProperty("sessionKey").unique().notNull(); //.unique()
    sessionInfo.addIntProperty("peerId").notNull();
    sessionInfo.addIntProperty("peerType").notNull();

    sessionInfo.addIntProperty("latestMsgType").notNull();
    sessionInfo.addIntProperty("latestMsgId").notNull();
    sessionInfo.addStringProperty("latestMsgData").notNull();

    sessionInfo.addIntProperty("talkId").notNull();
    sessionInfo.addIntProperty("created").notNull();
    sessionInfo.addIntProperty("updated").notNull();

    sessionInfo.setHasKeepSections(true);
}
 
Example 5
Source File: GreenDaoGenerator.java    From sctalk with Apache License 2.0 6 votes vote down vote up
private static void addDepartment(Schema schema){
    Entity department = schema.addEntity("DepartmentEntity");
    department.setTableName("Department");
    department.setClassNameDao("DepartmentDao");
    department.setJavaPackage(entityPath);

    department.addIdProperty().autoincrement();
    department.addIntProperty("departId").unique().notNull().index();
    department.addStringProperty("departName").unique().notNull().index();
    department.addIntProperty("priority").notNull();
    department.addIntProperty("status").notNull();

    department.addIntProperty("created").notNull();
    department.addIntProperty("updated").notNull();

    department.setHasKeepSections(true);
}
 
Example 6
Source File: BrainphaserDaoGenerator.java    From BrainPhaser with GNU General Public License v3.0 5 votes vote down vote up
public static Entity createChallengeEntity(Schema schema) {
    Entity challenge = schema.addEntity("Challenge");
    challenge.addIdProperty();
    challenge.addIntProperty("challengeType").notNull();
    challenge.addStringProperty("question").notNull();

    return challenge;
}
 
Example 7
Source File: EhDaoGenerator.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private static void addReadingRecord(Schema schema) {
    Entity entity = schema.addEntity("ReadingRecord");
    entity.setTableName("RECORDS");
    entity.setClassNameDao("ReadingRecordDao");
    entity.addStringProperty("id").primaryKey().notNull();
    entity.addLongProperty("update_time").notNull();
    entity.addLongProperty("read_time");
    entity.addStringProperty("chapter_info");
}
 
Example 8
Source File: BrainphaserDaoGenerator.java    From BrainPhaser with GNU General Public License v3.0 5 votes vote down vote up
public static Entity createSettingsEntity(Schema schema) {
    Entity settings = schema.addEntity("Settings");

    settings.addIdProperty();
    settings.addDateProperty("timeBoxStage1");
    settings.addDateProperty("timeBoxStage2");
    settings.addDateProperty("timeBoxStage3");
    settings.addDateProperty("timeBoxStage4");
    settings.addDateProperty("timeBoxStage5");
    settings.addDateProperty("timeBoxStage6");

    return settings;
}
 
Example 9
Source File: MyDaoGenerator.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
/**
 * 添加不同的缓存表
 * @param schema
 * @param tableName
 */
private static void addCache(Schema schema, String tableName) {

	Entity joke = schema.addEntity(tableName);

	//主键id自增长
	joke.addIdProperty().primaryKey().autoincrement();
	//请求结果
	joke.addStringProperty("result");
	//页数
	joke.addIntProperty("page");
	//插入时间,暂时无用
	joke.addLongProperty("time");

}
 
Example 10
Source File: MyDaoGenerator.java    From MyWeather with Apache License 2.0 5 votes vote down vote up
private static void addAlarms(Schema schema) {
    Entity weekForeCast = schema.addEntity("Alarms");
    weekForeCast.implementsSerializable();
    weekForeCast.addStringProperty("alarmContent");
    weekForeCast.addStringProperty("alarmId");
    weekForeCast.addStringProperty("alarmLevelNo");
    weekForeCast.addStringProperty("alarmLevelNoDesc");
    weekForeCast.addStringProperty("alarmType");
    weekForeCast.addStringProperty("alarmTypeDesc");
    weekForeCast.addStringProperty("publishTime");
    weekForeCast.addStringProperty("areaid");
    weekForeCast.addStringProperty("areaName");
}
 
Example 11
Source File: BrainphaserDaoGenerator.java    From BrainPhaser with GNU General Public License v3.0 5 votes vote down vote up
public static Entity createCompletedEntity(Schema schema) {
    Entity completed = schema.addEntity("Completion");
    completed.addIdProperty();
    completed.addIntProperty("stage");
    completed.addDateProperty("lastCompleted");

    return completed;
}
 
Example 12
Source File: DBClass02.java    From MeiZiNews with MIT License 5 votes vote down vote up
private static void addCollect(Schema schema) {

        // 实体类
        Entity mCollectEntity = schema.addEntity("CollectEntity");//表名

        //列名
        mCollectEntity.addIdProperty();//主键id
        mCollectEntity.addStringProperty("url");//连接
        mCollectEntity.addStringProperty("type");//连接类型
        mCollectEntity.addStringProperty("text");//名字

        mCollectEntity.addDateProperty("hireDate");
    }
 
Example 13
Source File: MyDaoGenerator.java    From JianDan with Apache License 2.0 5 votes vote down vote up
/**
 * 添加不同的缓存表
 * @param schema
 * @param tableName
 */
private static void addCache(Schema schema, String tableName) {

	Entity joke = schema.addEntity(tableName);

	//主键id自增长
	joke.addIdProperty().primaryKey().autoincrement();
	//请求结果
	joke.addStringProperty("result");
	//页数
	joke.addIntProperty("page");
	//插入时间,暂时无用
	joke.addLongProperty("time");

}
 
Example 14
Source File: NMBDaoGenerator.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
/**
 * @since 3
 */
private static void addACCommonPost(Schema schema) {
    Entity entity = schema.addEntity("ACCommonPostRaw");
    entity.setTableName("AC_COMMON_POST");
    entity.setClassNameDao("ACCommonPostDao");
    entity.addIdProperty();
    entity.addStringProperty("name");
    entity.addStringProperty("postid");
}
 
Example 15
Source File: EhDaoGenerator.java    From MHViewer with Apache License 2.0 5 votes vote down vote up
private static void addFilter(Schema schema) {
    Entity entity = schema.addEntity("Filter");
    entity.setTableName("FILTER");
    entity.setClassNameDao("FilterDao");
    entity.addIdProperty();
    entity.addIntProperty("mode").notNull();
    entity.addStringProperty("text");
    // Since 3
    entity.addBooleanProperty("enable");
}
 
Example 16
Source File: MyDaoGenerator.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
/**
 * 添加不同的缓存表
 * @param schema
 * @param tableName
 */
private static void addCache(Schema schema, String tableName) {

	Entity joke = schema.addEntity(tableName);

	//主键id自增长
	joke.addIdProperty().primaryKey().autoincrement();
	//请求结果
	joke.addStringProperty("result");
	//页数
	joke.addIntProperty("page");
	//插入时间,暂时无用
	joke.addLongProperty("time");

}
 
Example 17
Source File: Generator.java    From AndroidDatabaseLibraryComparison with MIT License 5 votes vote down vote up
static Entity getAddressItemEntity(Schema schema, String name) {
    Entity simpleAddressItem = schema.addEntity(name);
    simpleAddressItem.addIdProperty();
    simpleAddressItem.addStringProperty("name");
    simpleAddressItem.addStringProperty("address");
    simpleAddressItem.addStringProperty("city");
    simpleAddressItem.addStringProperty("state");
    simpleAddressItem.addLongProperty("phone");
    return simpleAddressItem;
}
 
Example 18
Source File: MyDaoGenerator.java    From MyWeather with Apache License 2.0 5 votes vote down vote up
private static void addRealWeather(Schema schema) {
    Entity realWeather = schema.addEntity("RealWeather");
    realWeather.addStringProperty("areaid");
    realWeather.addStringProperty("areaName");
    realWeather.addStringProperty("weatherCondition");
    realWeather.addStringProperty("fx");
    realWeather.addStringProperty("fj");
    realWeather.addIntProperty("temp");
    realWeather.addIntProperty("feeltemp");
    realWeather.addIntProperty("shidu");
    realWeather.addStringProperty("sunrise");
    realWeather.addStringProperty("sundown");
    realWeather.addDateProperty("lastUpdate");
}
 
Example 19
Source File: MyDaoGenerator.java    From MyWeather with Apache License 2.0 5 votes vote down vote up
private static void addZhishu(Schema schema) {
    Entity weekForeCast = schema.addEntity("Zhishu");
    weekForeCast.addStringProperty("areaid");
    weekForeCast.addStringProperty("name");
    weekForeCast.addStringProperty("level");
    weekForeCast.addStringProperty("text");
    weekForeCast.addStringProperty("detail");
}
 
Example 20
Source File: GreenDaoGenerator.java    From Dota2Helper with Apache License 2.0 4 votes vote down vote up
public static void addUpdate(Schema schema) {
    Entity updates = schema.addEntity("GreenUpdate");
    updates.addIdProperty();
    updates.addStringProperty("updatelistjson");
}