当前位置: 首页>>代码示例>>Java>>正文


Java Schema.enableKeepSectionsByDefault方法代码示例

本文整理汇总了Java中org.greenrobot.greendao.generator.Schema.enableKeepSectionsByDefault方法的典型用法代码示例。如果您正苦于以下问题:Java Schema.enableKeepSectionsByDefault方法的具体用法?Java Schema.enableKeepSectionsByDefault怎么用?Java Schema.enableKeepSectionsByDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.greenrobot.greendao.generator.Schema的用法示例。


在下文中一共展示了Schema.enableKeepSectionsByDefault方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createSchema2

import org.greenrobot.greendao.generator.Schema; //导入方法依赖的package包/类
private Schema createSchema2() {
    Schema schema2 = new Schema(1, "org.greenrobot.greendao.daotest2");
    schema2.setDefaultJavaPackageTest("org.greenrobot.greendao.daotest2.entity");
    schema2.setDefaultJavaPackageDao("org.greenrobot.greendao.daotest2.dao");
    schema2.enableKeepSectionsByDefault();

    Entity keepEntity = schema2.addEntity("KeepEntity");
    keepEntity.addIdProperty();

    Entity toManyTarget2 = schema2.addEntity("ToManyTarget2");
    toManyTarget2.addIdProperty();
    Property toManyTarget2FkId = toManyTarget2.addLongProperty("fkId").getProperty();
    toManyTarget2.setSkipGenerationTest(true);

    Entity toOneTarget2 = schema2.addEntity("ToOneTarget2");
    toOneTarget2.addIdProperty();
    toOneTarget2.setJavaPackage("org.greenrobot.greendao.daotest2.to1_specialentity");
    toOneTarget2.setJavaPackageDao("org.greenrobot.greendao.daotest2.to1_specialdao");
    toOneTarget2.setJavaPackageTest("org.greenrobot.greendao.daotest2.to1_specialtest");
    toOneTarget2.setSkipGenerationTest(true);

    Entity relationSource2 = schema2.addEntity("RelationSource2");
    relationSource2.addIdProperty();
    relationSource2.addToMany(toManyTarget2, toManyTarget2FkId);
    Property toOneId = relationSource2.addLongProperty("toOneId").getProperty();
    relationSource2.addToOne(toOneTarget2, toOneId);
    relationSource2.setJavaPackage("org.greenrobot.greendao.daotest2.specialentity");
    relationSource2.setJavaPackageDao("org.greenrobot.greendao.daotest2.specialdao");
    relationSource2.setJavaPackageTest("org.greenrobot.greendao.daotest2.specialtest");
    relationSource2.setSkipGenerationTest(true);
    return schema2;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:TestDaoGenerator.java

示例2: main

import org.greenrobot.greendao.generator.Schema; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
    //创建了一个用于添加实体(Entity)的模式(Schema)对象。
    Schema schema = new Schema(1, "com.example.jp");
    schema.enableKeepSectionsByDefault();//加入自己的一些信息,下次生成的时候不消失
    //一个实体(类)就关联到数据库中的一张表,此处表名为User(类名)
    Entity userBean = schema.addEntity("User");

    //添加字段
    userBean.addIdProperty();
    userBean.addStringProperty("number");
    userBean.addStringProperty("password");

    //生成DAO
    new DaoGenerator().generateAll(schema, "app/src/main/java-gen");
}
 
开发者ID:jp1017,项目名称:greenDAO-demo,代码行数:16,代码来源:DaoGen.java

示例3: main

import org.greenrobot.greendao.generator.Schema; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {


        Schema schema = new Schema(8, "com.lidchanin.crudindiploma.database");
        schema.setDefaultJavaPackageDao("com.lidchanin.crudindiploma.database.dao");
        schema.enableKeepSectionsByDefault();

        Entity shoppingList = schema.addEntity("ShoppingList");
        shoppingList.addIdProperty()
                .codeBeforeField("/* id */");
        shoppingList.addStringProperty("name").notNull()
                .codeBeforeField("/* shopping list name */");
        shoppingList.addLongProperty("date").notNull()
                .codeBeforeField("/* date of creation */");

        Entity product = schema.addEntity("Product");
        product.addIdProperty()
                .codeBeforeField("/* id */");
        product.addStringProperty("name").notNull().unique()
                .codeBeforeField("/* product name */");
        product.addDoubleProperty("cost").notNull()
                .codeBeforeField("/* product cost */");

        Entity usedProduct = schema.addEntity("UsedProduct");
        usedProduct.addIdProperty()
                .codeBeforeField("/* id */");
        usedProduct.addDoubleProperty("quantity").notNull()
                .codeBeforeField("/* used product quantity */");
        usedProduct.addBooleanProperty("unit").notNull()
                .codeBeforeField("/* true -> kg, false -> pieces */");
        usedProduct.addBooleanProperty("isPurchased").notNull()
                .codeBeforeField("/* true -> purchased, false -> not */");
        usedProduct.addLongProperty("date").notNull().unique()
                .codeBeforeField("/* date when the product in the shopping list was marked as" +
                        " purchased */");

        Entity statistic = schema.addEntity("Statistic");
        statistic.addIdProperty()
                .codeBeforeField("/* id */");
        statistic.addStringProperty("name").notNull()
                .codeBeforeField("/* product name */");
        statistic.addDoubleProperty("quantity").notNull()
                .codeBeforeField("/* used product quantity */");
        statistic.addDoubleProperty("totalCost").notNull()
                .codeBeforeField("/* product cost * used product quantity * product cost */");
        statistic.addBooleanProperty("unit").notNull()
                .codeBeforeField("/* true -> kg, false -> pieces */");
        statistic.addLongProperty("date").notNull()
                .codeBeforeField("/* date when the product in the shopping list was marked as" +
                        " purchased */");

        //Creating One-To-One relation, used product has "one" product
        Property productId = usedProduct.addLongProperty("productId").getProperty();
        usedProduct.addToOne(product, productId);

        //Creating One-To-Many relation, shopping list has "many" used products
        Property shoppingListIdProperty = usedProduct.addLongProperty("shoppingListId")
                .notNull().getProperty();
        ToMany shoppingListToExistingProducts = shoppingList.addToMany(usedProduct,
                shoppingListIdProperty);
        shoppingListToExistingProducts.setName("usedProducts");

        new DaoGenerator().generateAll(schema, "../app/src/main/java");
    }
 
开发者ID:Lidchanin,项目名称:Shopping_List,代码行数:65,代码来源:GreenDaoGenerator.java


注:本文中的org.greenrobot.greendao.generator.Schema.enableKeepSectionsByDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。