Java Code Examples for de.greenrobot.daogenerator.Entity#addStringProperty()

The following examples show how to use de.greenrobot.daogenerator.Entity#addStringProperty() . 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: EhDaoGenerator.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private static void addBookmarks(Schema schema) {
    Entity entity = schema.addEntity("BookmarkInfo");
    entity.setTableName("BOOKMARKS");
    entity.setClassNameDao("BookmarksBao");
    entity.setSuperclass("GalleryInfo");
    // GalleryInfo data
    entity.addLongProperty("gid").primaryKey().notNull();
    entity.addStringProperty("token");
    entity.addStringProperty("title");
    entity.addStringProperty("titleJpn");
    entity.addStringProperty("thumb");
    entity.addIntProperty("category").notNull();
    entity.addStringProperty("posted");
    entity.addStringProperty("uploader");
    entity.addFloatProperty("rating").notNull();
    entity.addStringProperty("simpleLanguage");
    // Bookmark data
    entity.addIntProperty("page").notNull();
    entity.addLongProperty("time").notNull();
}
 
Example 2
Source File: DBClass.java    From MeiZiNews with MIT License 6 votes vote down vote up
private static void addHtml(Schema schema) {

        // 实体类
        Entity mHtmlEntity = schema.addEntity("HtmlEntity");//表名

        //列名
        mHtmlEntity.addIdProperty();//主键id
        mHtmlEntity.addStringProperty("url");//连接
        mHtmlEntity.addStringProperty("type");//类型
        mHtmlEntity.addStringProperty("title");//标题
        mHtmlEntity.addStringProperty("html");//html
        mHtmlEntity.addStringProperty("summary");//总结
        mHtmlEntity.addStringProperty("collect");//是否收藏



        mHtmlEntity.addDateProperty("hireDate");


        // 收藏实体类
        Entity mCollectEntity = schema.addEntity("CollectEntity");//表名
        mCollectEntity.addIdProperty();//主键id
        Property htmlID =   mCollectEntity.addLongProperty("html_id").getProperty();//收藏的id
        mCollectEntity.addStringProperty("collect");//是否收藏
        mCollectEntity.addToOne(mHtmlEntity, htmlID);
    }
 
Example 3
Source File: Generator.java    From android-orm-benchmark with Apache License 2.0 6 votes vote down vote up
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();
    }
}
 
Example 4
Source File: EhDaoGenerator.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private static void addQuickSearch(Schema schema) {
    Entity entity = schema.addEntity("QuickSearch");
    entity.setTableName("QUICK_SEARCH");
    entity.setClassNameDao("QuickSearchDao");
    entity.addIdProperty();
    entity.addStringProperty("name");
    entity.addIntProperty("mode").notNull();
    entity.addIntProperty("category").notNull();
    entity.addStringProperty("keyword");
    entity.addIntProperty("advanceSearch").notNull();
    entity.addIntProperty("minRating").notNull();
    // Since 4
    entity.addIntProperty("pageFrom").notNull();
    // Since 4
    entity.addIntProperty("pageTo").notNull();
    entity.addLongProperty("time").notNull();
}
 
Example 5
Source File: GreenDaoGenerator.java    From DMusic with Apache License 2.0 6 votes vote down vote up
/**
 * 添加公共字段
 */
private static void addProperty(Entity entity) {
    entity.addStringProperty("id").primaryKey(); // 文件完整路径---主键

    entity.addIntProperty("type"); // 类型:本地、百度、网易、QQ等
    entity.addIntProperty("seq"); // 自定义序号
    entity.addStringProperty("songId"); // 歌曲ID
    entity.addStringProperty("songName"); // 歌曲名
    entity.addStringProperty("songUrl"); // 歌曲url
    entity.addStringProperty("artistId"); // 艺术家ID
    entity.addStringProperty("artistName"); // 歌手名
    entity.addStringProperty("albumId"); // 专辑ID
    entity.addStringProperty("albumName"); // 专辑
    entity.addStringProperty("albumUrl"); // 专辑url
    entity.addStringProperty("lrcName"); // 歌词名称
    entity.addStringProperty("lrcUrl"); // 歌词路径

    entity.addLongProperty("fileDuration"); // 歌曲时长
    entity.addLongProperty("fileSize"); // 文件大小
    entity.addStringProperty("filePostfix"); // 文件后缀类型
    entity.addStringProperty("fileFolder"); // 父文件夹绝对路径

    entity.addBooleanProperty("isCollected"); // 是否收藏
    entity.addLongProperty("timeStamp"); // 时间戳,插入时间
}
 
Example 6
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 7
Source File: EhDaoGenerator.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private static void addLocalFavorites(Schema schema) {
    Entity entity = schema.addEntity("LocalFavoriteInfo");
    entity.setTableName("LOCAL_FAVORITES");
    entity.setClassNameDao("LocalFavoritesDao");
    entity.setSuperclass("GalleryInfo");
    // GalleryInfo data
    entity.addLongProperty("gid").primaryKey().notNull();
    entity.addStringProperty("token");
    entity.addStringProperty("title");
    entity.addStringProperty("titleJpn");
    entity.addStringProperty("thumb");
    entity.addIntProperty("category").notNull();
    entity.addStringProperty("posted");
    entity.addStringProperty("uploader");
    entity.addFloatProperty("rating").notNull();
    entity.addStringProperty("simpleLanguage");
    // LocalFavoriteInfo data
    entity.addLongProperty("time").notNull();
}
 
Example 8
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 9
Source File: EhDaoGenerator.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
private static void addDownloads(Schema schema) {
    Entity entity = schema.addEntity("DownloadInfo");
    entity.setTableName("DOWNLOADS");
    entity.setClassNameDao("DownloadsDao");
    entity.setSuperclass("GalleryInfo");
    // GalleryInfo data
    entity.addStringProperty("gid").primaryKey().notNull();
    entity.addStringProperty("token");
    entity.addStringProperty("title");
    entity.addStringProperty("titleJpn");
    entity.addStringProperty("thumb");
    entity.addIntProperty("category").notNull();
    entity.addStringProperty("posted");
    entity.addStringProperty("uploader");
    entity.addFloatProperty("rating").notNull();
    entity.addStringProperty("simpleLanguage");
    // DownloadInfo data
    entity.addIntProperty("state").notNull();
    entity.addIntProperty("legacy").notNull();
    entity.addLongProperty("time").notNull();
    entity.addStringProperty("label");
}
 
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: Generator.java    From android-opensource-library-56 with Apache License 2.0 5 votes vote down vote up
private static void createTodoSchema(Schema schema){
    Entity todo = schema.addEntity("Todo");
    Property id = todo.addIdProperty().getProperty();
    todo.addStringProperty("todo");
    todo.addDateProperty("addDate").notNull();
    todo.addDateProperty("endDate");
    todo.addIntProperty("status").notNull().unique();
}
 
Example 12
Source File: MyDaoGenerator.java    From MyWeather with Apache License 2.0 5 votes vote down vote up
private static void addForeCast(Schema schema) {
    Entity weekForeCast = schema.addEntity("WeekForeCast");
    weekForeCast.addStringProperty("areaid");
    weekForeCast.addDateProperty("weatherDate");
    weekForeCast.addStringProperty("weatherConditionStart");
    weekForeCast.addStringProperty("weatherConditionEnd");
    weekForeCast.addIntProperty("tempH");
    weekForeCast.addIntProperty("tempL");
    weekForeCast.addStringProperty("fx");
    weekForeCast.addStringProperty("fj");
    weekForeCast.addIntProperty("rainPerCent");
}
 
Example 13
Source File: MyDaoGenerator.java    From MyWeather with Apache License 2.0 5 votes vote down vote up
private static void addAqi(Schema schema) {
    Entity weekForeCast = schema.addEntity("Aqi");
    weekForeCast.addStringProperty("areaid");
    weekForeCast.addIntProperty("aqi");
    weekForeCast.addStringProperty("quality");
    weekForeCast.addIntProperty("pm2_5");
    weekForeCast.addIntProperty("pm10");
    weekForeCast.addIntProperty("so2");
    weekForeCast.addIntProperty("no2");
}
 
Example 14
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 15
Source File: MyDaoGenerator.java    From 30-android-libraries-in-30-days with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Schema schema = new Schema(1, "com.devahoy.learn30androidlibraries");
    Entity player = schema.addEntity("Player");

    player.addIdProperty();
    player.addStringProperty("name");
    player.addStringProperty("club");

    new DaoGenerator().generateAll(schema, args[0]);
}
 
Example 16
Source File: Generator.java    From AndroidDatabaseLibraryComparison with MIT License 5 votes vote down vote up
static Entity getAddressBookEntity(Schema schema) {
    Entity addressBook = schema.addEntity("AddressBook");
    addressBook.addIdProperty();
    addressBook.addStringProperty("name");
    addressBook.addStringProperty("author");
    return addressBook;
}
 
Example 17
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 18
Source File: DBClass02.java    From MeiZiNews with MIT License 5 votes vote down vote up
private static void addTokyopornVideo(Schema schema) {

        // 实体类
        Entity mTokyopornVideoEntity = schema.addEntity("TokyopornVideoEntity");//表名

        //列名
        mTokyopornVideoEntity.addIdProperty();//主键id
        mTokyopornVideoEntity.addStringProperty("url");//连接
        mTokyopornVideoEntity.addStringProperty("html");//html
        mTokyopornVideoEntity.addStringProperty("text");//名字
        mTokyopornVideoEntity.addStringProperty("videoUrl");//video url

        mTokyopornVideoEntity.addDateProperty("hireDate");
    }
 
Example 19
Source File: GreenDaoGenerator.java    From Dota2Helper with Apache License 2.0 4 votes vote down vote up
public static void addStrategy(Schema schema) {
    Entity strategies = schema.addEntity("GreenStrategy");
    strategies.addIdProperty();
    strategies.addStringProperty("strategylistjson");
    strategies.addStringProperty("strategytype");
}
 
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");
}