de.greenrobot.daogenerator.DaoGenerator Java Examples

The following examples show how to use de.greenrobot.daogenerator.DaoGenerator. 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: GreenDaoGenerator.java    From DMusic with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    // 正如你所见的,你创建了一个用于添加实体(Entity)的模式(Schema)对象。
    // 两个参数分别代表:数据库版本号与自动生成代码的包路径。
    // Schema schema = new Schema(1, "com.d.music.data.database.greendao.music");
    // 当然,如果你愿意,你也可以分别指定生成的 Bean 与 DAO 类所在的目录,只要如下所示:
    Schema schema = new Schema(1, "com.d.music.data.database.greendao.bean");
    schema.setDefaultJavaPackageDao("com.d.music.data.database.greendao.dao");

    // 模式(Schema)同时也拥有两个默认的 flags,分别用来标示 entity 是否是 activie 以及是否使用 keep sections。
    // schema2.enableActiveEntitiesByDefault();
    // schema2.enableKeepSectionsByDefault();

    // 一旦你拥有了一个 Schema 对象后,你便可以使用它添加实体(Entities)了。
    addMusic(schema);
    addLocalAllMusic(schema);
    addCollectionMusic(schema);
    addCustomList(schema);
    addCustomMusics(schema);
    addTransferModel(schema);

    // 最后我们将使用 DAOGenerator 类的 generateAll() 方法自动生成代码,此处你需要根据自己的情况更改输出目录。
    // 其实,输出目录的路径可以在 build.gradle 中设置,有兴趣的朋友可以自行搜索,这里就不再详解。
    // 重新运行GreenDaoGenerator时,将此路径更改为本地src路径
    new DaoGenerator().generateAll(schema, "D:\\AndroidStudioProjects\\DMusic\\app\\src\\main\\java");
}
 
Example #2
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 #3
Source File: EhDaoGenerator.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
public static void generate() throws Exception {
    Utilities.deleteContents(new File(DELETE_DIR));
    File outDir = new File(OUT_DIR);
    outDir.delete();
    outDir.mkdirs();

    Schema schema = new Schema(VERSION, PACKAGE);
    addDownloads(schema);
    addDownloadLabel(schema);
    addDownloadDirname(schema);
    addHistoryInfo(schema);
    addQuickSearch(schema);
    addLocalFavorites(schema);
    addBookmarks(schema);
    addFilter(schema);
    new DaoGenerator().generateAll(schema, OUT_DIR);

    adjustDownloadInfo();
    adjustHistoryInfo();
    adjustQuickSearch();
    adjustLocalFavoriteInfo();
    adjustBookmarkInfo();
    adjustFilter();
}
 
Example #4
Source File: Generator.java    From AndroidDatabaseLibraryComparison with MIT License 6 votes vote down vote up
public static void main(String[] args) {
    Schema schema = new Schema(1, "com.raizlabs.android.databasecomparison.greendao.gen");


    Entity simpleAddressItem = getAddressItemEntity(schema, "SimpleAddressItem");

    Entity addressItem = getAddressItemEntity(schema, "AddressItem");
    Entity contactItem = getContactItemEntity(schema);

    Entity addressBook = getAddressBookEntity(schema);

    addressItem.addToOne(addressBook,  addressItem.getProperties().get(0));
    contactItem.addToOne(addressBook,  contactItem.getProperties().get(0));
    addressBook.addToMany(addressItem, addressItem.getProperties().get(0));
    addressBook.addToMany(contactItem, contactItem.getProperties().get(0));

    try {
        new DaoGenerator().generateAll(schema,
                "../app/src/main/java");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #5
Source File: EhDaoGenerator.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
public static void generate() throws Exception {
    Utilities.deleteContents(new File(DELETE_DIR));
    File outDir = new File(OUT_DIR);
    outDir.delete();
    outDir.mkdirs();

    Schema schema = new Schema(VERSION, PACKAGE);
    addReadingRecord(schema);
    addDownloads(schema);
    addDownloadLabel(schema);
    addDownloadDirname(schema);
    addHistoryInfo(schema);
    addQuickSearch(schema);
    addLocalFavorites(schema);
    addBookmarks(schema);
    addFilter(schema);
    new DaoGenerator().generateAll(schema, OUT_DIR);

    adjustDownloadInfo();
    adjustHistoryInfo();
    adjustQuickSearch();
    adjustLocalFavoriteInfo();
    adjustBookmarkInfo();
    adjustFilter();
}
 
Example #6
Source File: MyDaoGenerator.java    From JianDanRxJava with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

		Schema schema = new Schema(DATA_VERSION_CODE, PACKAGE_NAME);
		addCache(schema, "JokeCache");
		addCache(schema, "FreshNewsCache");
		addCache(schema, "PictureCache");
		addCache(schema, "SisterCache");
		addCache(schema, "VideoCache");
		//生成Dao文件路径
		new DaoGenerator().generateAll(schema, DAO_PATH);

	}
 
Example #7
Source File: Generator.java    From android-opensource-library-56 with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    try {
        Schema schema = new Schema(1, "jp.mydns.sys1yagi.android.greendaosample");
        
        createTodoSchema(schema);
        
        new DaoGenerator().generateAll(schema, "../GreenDaoSample/src");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
Example #8
Source File: GreenDaoGenerator.java    From sctalk with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    int dbVersion = 12;
    Schema schema = new Schema(dbVersion, "com.mogujie.tt.DB.dao");

    schema.enableKeepSectionsByDefault();
    addDepartment(schema);
    addUserInfo(schema);
    addGroupInfo(schema);
    addMessage(schema);
    addSessionInfo(schema);

    // todo 绝对路径,根据自己的路径设定, 例子如下
    String path = "/Users/yingmu/software/IM/TT/ttandroidclientnew/app/src/main/java";
    new DaoGenerator().generateAll(schema, path);
}
 
Example #9
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 #10
Source File: MyDaoGenerator.java    From JianDan_OkHttp with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

		Schema schema = new Schema(DATA_VERSION_CODE, PACKAGE_NAME);
		addCache(schema, "JokeCache");
		addCache(schema, "FreshNewsCache");
		addCache(schema, "PictureCache");
		addCache(schema, "SisterCache");
		addCache(schema, "VideoCache");
		//生成Dao文件路径
		new DaoGenerator().generateAll(schema, DAO_PATH);

	}
 
Example #11
Source File: GreenDaoGenerator.java    From Dota2Helper 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.fangxu.dota2helper.greendao");
    addNews(schema);
    addStrategy(schema);
    addUpdate(schema);
    addVideo(schema);
    addHistoryVideo(schema);
    new DaoGenerator().generateAll(schema, "../Dota2Helper/app/src/main/java-gen");
}
 
Example #12
Source File: MyDaoGenerator.java    From JianDan with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

		Schema schema = new Schema(DATA_VERSION_CODE, PACKAGE_NAME);
		addCache(schema, "JokeCache");
		addCache(schema, "FreshNewsCache");
		addCache(schema, "PictureCache");
		addCache(schema, "SisterCache");
		addCache(schema, "VideoCache");
		//生成Dao文件路径
		new DaoGenerator().generateAll(schema, DAO_PATH);

	}
 
Example #13
Source File: DaoGeneration.java    From NBAPlus 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.me.silencedut.greendao");
        addNews(schema);
        addStats(schema);
        new DaoGenerator().generateAll(schema, "/.../NBAPlus/app/src/main/java-gen");
    }
 
Example #14
Source File: MyDaoGenerator.java    From JianDan_OkHttpWithVolley with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

		Schema schema = new Schema(DATA_VERSION_CODE, PACKAGE_NAME);
		addCache(schema, "JokeCache");
		addCache(schema, "FreshNewsCache");
		addCache(schema, "PictureCache");
		addCache(schema, "SisterCache");
		addCache(schema, "VideoCache");
		//生成Dao文件路径
		new DaoGenerator().generateAll(schema, DAO_PATH);

	}
 
Example #15
Source File: NMBDaoGenerator.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
public static void generate() throws Exception {
    Utilities.deleteContents(new File(DELETE_DIR));
    File outDir = new File(OUT_DIR);
    outDir.delete();
    outDir.mkdirs();

    Schema schema = new Schema(VERSION, PACKAGE);
    addACForum(schema);
    addDraft(schema);
    addACRecord(schema);
    addACCommonPost(schema);
    new DaoGenerator().generateAll(schema, OUT_DIR);
}
 
Example #16
Source File: HttpCookieDaoGenerator.java    From Nimingban with Apache License 2.0 5 votes vote down vote up
public static void generate() throws Exception {
    Utilities.deleteContents(new File(DELETE_DIR));
    File outDir = new File(OUT_DIR);
    outDir.delete();
    outDir.mkdirs();

    Schema schema = new Schema(1, PACKAGE);
    addHttpCookie(schema);
    new DaoGenerator().generateAll(schema, OUT_DIR);
}
 
Example #17
Source File: MyDaoGenerator.java    From MyWeather with Apache License 2.0 5 votes vote down vote up
public static void main(String args[]) throws Exception {
    Schema schema = new Schema(2, "suda.sudamodweather.dao.greendao");
    addForeCast(schema);
    addRealWeather(schema);
    addHourForeCast(schema);
    addAqi(schema);
    addZhishu(schema);
    addUseArea(schema);
    addAlarms(schema);
    new DaoGenerator().generateAll(schema, "app/src/main/java");
}
 
Example #18
Source File: DBClass.java    From MeiZiNews with MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Schema schema = new Schema(DBVERSION, "com.ms.greendaolibrary.db");

    addHtml(schema);
    addCollect(schema);
    // 生成
    new DaoGenerator().generateAll(
            schema,
            "D:\\mypojo\\pojo\\demo\\MeiZiNewsApplication\\greendaolibrary\\src\\main\\java"
    );
}
 
Example #19
Source File: DBClass02.java    From MeiZiNews with MIT License 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    Schema schema = new Schema(DBVERSION, "com.ms.greendaolibrary.db");

    addCollect(schema);
    addTokyopornVideo(schema);
    // 生成
    new DaoGenerator().generateAll(
            schema,
            "D:\\mypojo\\pojo\\demo\\ImgShow\\greendaolibrary\\src\\main\\java"
    );
}
 
Example #20
Source File: BrainphaserDaoGenerator.java    From BrainPhaser with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String args[]) throws Exception {
    Schema schema = new Schema(DATABASE_VERSION, "de.fhdw.ergoholics.brainphaser.model");

    // Create entities
    Entity userEntity = createUserEntity(schema);
    Entity categoryEntity = createCategoryEntity(schema);
    Entity challengeEntity = createChallengeEntity(schema);
    Entity answerEntity = createAnswerEntity(schema);
    Entity completedEntity = createCompletedEntity(schema);
    Entity settingsEntity = createSettingsEntity(schema);
    Entity statisticsEntity = createStatisticsEntity(schema);

    // category HAS MANY challenge
    Property categoryId = challengeEntity.addLongProperty("categoryId").notNull().getProperty();
    ToMany categoryToChallenge = categoryEntity.addToMany(challengeEntity, categoryId);
    categoryToChallenge.setName("challenges");

    // challenge HAS MANY answer
    Property challengeIdAnswer = answerEntity.addLongProperty("challengeId").notNull().getProperty();
    ToMany challengeToAnswer = challengeEntity.addToMany(answerEntity, challengeIdAnswer);
    challengeToAnswer.setName("answers");

    // user HAS MANY completion
    Property userIdCompleted = completedEntity.addLongProperty("userId").notNull().getProperty();
    ToMany userToCompleted = userEntity.addToMany(completedEntity, userIdCompleted);
    userToCompleted.setName("completions");

    // completion TO ONE challenge
    Property challengeIdCompleted = completedEntity.addLongProperty("challengeId").notNull().getProperty();
    ToOne completedToChallenge = completedEntity.addToOne(challengeEntity, challengeIdCompleted);
    completedToChallenge.setName("challenge");

    // user HAS MANY statistics
    Property userIdStatistics = statisticsEntity.addLongProperty("userId").notNull().getProperty();
    ToMany userToStatistics = userEntity.addToMany(statisticsEntity, userIdStatistics);
    userToStatistics.setName("statistics");

    // statistics TO ONE challenge
    Property challengeIdStatistics = statisticsEntity.addLongProperty("challengeId").notNull().getProperty();
    ToOne completedToStatistics = statisticsEntity.addToOne(challengeEntity, challengeIdStatistics);
    completedToStatistics.setName("statistic");

    // user HAS ONE settings
    Property userIdSettings = userEntity.addLongProperty("settingsId").notNull().getProperty();
    ToOne userToSettings = userEntity.addToOne(settingsEntity, userIdSettings);
    userToSettings.setName("settings");

    new DaoGenerator().generateAll(schema, "../app/src/main/java/");
}
 
Example #21
Source File: DbDaoGenerator.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Schema schema = new Schema(1, getGenerateSchemaPath);
    addNote(schema);
    new DaoGenerator().generateAll(schema, generatePath);
}
 
Example #22
Source File: DbDaoGenerator.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Schema schema = new Schema(1, getGenerateSchemaPath);
    addNote(schema);
    new DaoGenerator().generateAll(schema, generatePath);
}
 
Example #23
Source File: MyGreenDAOGenerator.java    From Maps with GNU General Public License v2.0 3 votes vote down vote up
public static void main(String[] args) throws Exception {
    // 正如你所见的,你创建了一个用于添加实体(Entity)的模式(Schema)对象。
    // 两个参数分别代表:数据库版本号与自动生成代码的包路径。
    Schema schema = new Schema(1, "org.zarroboogs.maps.beans");

    schema.setDefaultJavaPackageDao("org.zarroboogs.maps.dao");
    //当然,如果你愿意,你也可以分别指定生成的 Bean 与 DAO 类所在的目录,只要如下所示:
    //Schema schema = new Schema(1, "me.itangqi.bean");
    //schema.setDefaultJavaPackageDao("me.itangqi.dao");

    // 模式(Schema)同时也拥有两个默认的 flags,分别用来标示 entity 是否是 activie 以及是否使用 keep sections。
    // schema2.enableActiveEntitiesByDefault();
    // schema2.enableKeepSectionsByDefault();

    // 一旦你拥有了一个 Schema 对象后,你便可以使用它添加实体(Entities)了。
    addCameraTable(schema);

    addPoiSearchTipTable(schema);

    // 最后我们将使用 DAOGenerator 类的 generateAll() 方法自动生成代码,此处你需要根据自己的情况更改输出目录(既之前创建的 java-gen)。
    // 其实,输出目录的路径可以在 build.gradle 中设置,有兴趣的朋友可以自行搜索,这里就不再详解。


    new DaoGenerator().generateAll(schema, "app/src/main/java-gen");


}
 
Example #24
Source File: GreenDaoGen.java    From iBeebo with GNU General Public License v3.0 3 votes vote down vote up
public static void main(String[] args) throws Exception {
    Schema schema = new Schema(DB_VERSION, "org.zarroboogs.weibo.greendao.bean");

    schema.setDefaultJavaPackageDao("org.zarroboogs.weibo.greendao.dao");

    addAccountTable(schema);

    addAtUsersTable(schema);

    addStatusTable(schema);

    new DaoGenerator().generateAll(schema, "app/src/main/java-greendao-gen");

}
 
Example #25
Source File: GreenDaoGen.java    From iBeebo with GNU General Public License v3.0 3 votes vote down vote up
public static void main(String[] args) throws Exception {
    Schema schema = new Schema(DB_VERSION, "org.zarroboogs.weibo.greendao.bean");

    schema.setDefaultJavaPackageDao("org.zarroboogs.weibo.greendao.dao");

    addAccountTable(schema);

    addAtUsersTable(schema);

    addStatusTable(schema);

    new DaoGenerator().generateAll(schema, "app/src/main/java-greendao-gen");

}
 
Example #26
Source File: Generator.java    From android-sholi with GNU General Public License v3.0 3 votes vote down vote up
public static void main(String[] args) throws Exception {
    Schema schema = new Schema(SCHEMA_VERSION, "name.soulayrol.rhaa.sholi.data.model");

    addItem(schema);

    new DaoGenerator().generateAll(schema, GEN_PATH);
}
 
Example #27
Source File: PrinterDaoGenerator.java    From octoandroid with GNU General Public License v3.0 3 votes vote down vote up
public static void main(String[] args) throws Exception {
    Schema schema = new Schema(DB_VERSION, DEFAULT_JAVA_PACKAGE);

    addTables(schema);

    new DaoGenerator().generateAll(schema, OUT_DIR);
}