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


Java ToMany.setName方法代码示例

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


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

示例1: addCustomerOrder

import de.greenrobot.daogenerator.ToMany; //导入方法依赖的package包/类
/**
 * @author:keivn
 * @param schema
 */
private static void addCustomerOrder(Schema schema) {
    Entity customer = schema.addEntity("Customer");
    customer.addIdProperty();
    customer.addStringProperty("name").notNull();

    Entity order = schema.addEntity("Order");
    order.setTableName("ORDERS"); // "ORDER" is a reserved keyword
    order.addIdProperty();
    Property orderDate = order.addDateProperty("date").getProperty();
    Property customerId = order.addLongProperty("customerId").notNull().getProperty();
    order.addToOne(customer, customerId);

    ToMany customerToOrders = customer.addToMany(order, customerId);
    customerToOrders.setName("orders");
    customerToOrders.orderAsc(orderDate);
}
 
开发者ID:DroidKOF,项目名称:pineapple,代码行数:21,代码来源:PineappleGenerator.java

示例2: addCustomerOrder

import de.greenrobot.daogenerator.ToMany; //导入方法依赖的package包/类
private static void addCustomerOrder(Schema schema) {
    Entity customer = schema.addEntity("Customer");
    customer.addIdProperty();
    customer.addStringProperty("name").notNull();

    Entity order = schema.addEntity("Order");
    order.setTableName("ORDERS"); // "ORDER" is a reserved keyword
    order.addIdProperty();
    Property orderDate = order.addDateProperty("date").getProperty();
    Property customerId = order.addLongProperty("customerId").notNull().getProperty();
    order.addToOne(customer, customerId);

    ToMany customerToOrders = customer.addToMany(order, customerId);
    customerToOrders.setName("orders");
    customerToOrders.orderAsc(orderDate);
}
 
开发者ID:cymcsg,项目名称:UltimateAndroid,代码行数:17,代码来源:DbDaoGenerator.java

示例3: setBidirectionalToMany

import de.greenrobot.daogenerator.ToMany; //导入方法依赖的package包/类
/**
 * Adds a toMany relationship to oneEntity, and a toOne relationship to manyEntity.
 * The property names will be the names specified, and the Ids will be the names of the
 * respective entities with the suffix of "DaoId"
 *
 *
 * @param oneEntity entity that only will be linking to manyEntities
 * @param manyEntity entity that will be linking to oneEntity
 * @param toOnePropertyName to specify the property name, otherwise null works
 * @param toManyPropertyName to specify the property name, otherwise null works
 *
 */
private static void setBidirectionalToMany(Entity oneEntity, Entity manyEntity,
                                           String toOnePropertyName,
                                           String toManyPropertyName){
    Property manyIdProp;
    if (toOnePropertyName == null) {
        manyIdProp = manyEntity.addLongProperty(oneEntity.getClassName() + "DaoId").getProperty();
    }else{
        manyIdProp = manyEntity.addLongProperty(toOnePropertyName + "DaoId").getProperty();
    }
    ToOne toOne = manyEntity.addToOne(oneEntity, manyIdProp);
    ToMany toMany = oneEntity.addToMany(manyEntity, manyIdProp);

    if(toOnePropertyName == null){
        toOnePropertyName = oneEntity.getClassName();
        toOnePropertyName = toOnePropertyName.substring(0, 1).toLowerCase() +
                toOnePropertyName.substring(1);
    }

    if(toManyPropertyName == null){
        toManyPropertyName = oneEntity.getClassName();
        toManyPropertyName = toManyPropertyName.substring(0, 1).toLowerCase() +
                toManyPropertyName.substring(1) + "s";
    }

    toOne.setName(toOnePropertyName);
    toMany.setName(toManyPropertyName);
}
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:40,代码来源:Generator.java

示例4: setManyToMany

import de.greenrobot.daogenerator.ToMany; //导入方法依赖的package包/类
private static void setManyToMany(Entity linkEntity, Entity entityOne, Entity entityTwo){

        Property entityOneProp;
        Property entityTwoProp;
        String entityOneName = entityOne.getClassName();
        String entityTwoName = entityTwo.getClassName();

        // Distinguish entity links if they are to the same entity type
        if(entityOne.getClassName().equals(entityTwo.getClassName())) {
            entityTwoName = "linkOwner" + entityTwoName;
        }

        entityOneProp = linkEntity.addLongProperty(entityOneName + "DaoId").getProperty();
        entityTwoProp = linkEntity.addLongProperty(entityTwoName + "DaoId").getProperty();

        linkEntity.addToOne(entityOne, entityOneProp).setName(entityOneName);
        linkEntity.addToOne(entityTwo, entityTwoProp).setName(entityTwoName);

        String linkEntityName = linkEntity.getClassName();
        linkEntityName = linkEntityName.substring(0, 1).toLowerCase() +
                linkEntityName.substring(1) + "s";

        ToMany linkFromEntityOne = entityOne.addToMany(linkEntity, entityOneProp);
        linkFromEntityOne.setName(linkEntityName);

        // If the entities are not the same they each need a property
        if(!entityOne.getClassName().equals(entityTwo.getClassName())) {
            ToMany linkFromEntityTwo = entityTwo.addToMany(linkEntity, entityTwoProp);
            linkFromEntityTwo.setName(linkEntityName);
        }
    }
 
开发者ID:MobileDev418,项目名称:AndroidBackendlessChat,代码行数:32,代码来源:Generator.java

示例5: addEntities

import de.greenrobot.daogenerator.ToMany; //导入方法依赖的package包/类
private static void addEntities(Schema schema) {
    Entity repository = schema.addEntity("Repository");
    repository.addIdProperty().index();
    repository.addStringProperty("url").notNull().unique().index();
    repository.addStringProperty("alias");
    repository.addBooleanProperty("hidden").index();
    repository.addIntProperty("order");
    repository.addDateProperty("lastUpdateDate");

    Entity category = schema.addEntity("Category");
    category.addIdProperty().index();
    category.addStringProperty("name");
    category.addBooleanProperty("hidden").index();
    category.addDateProperty("lastUpdateDate").index();
    Property repositoryId = category.addLongProperty("repositoryId").index().getProperty();
    category.addToOne(repository, repositoryId);

    ToMany repositoryToCategories = repository.addToMany(category, repositoryId);
    repositoryToCategories.setName("categories");

    Entity entry = schema.addEntity("Entry");
    entry.addIdProperty().index();
    entry.addStringProperty("emoticon").notNull();
    entry.addStringProperty("description");
    entry.addBooleanProperty("star").index();
    Property lastUsed = entry.addDateProperty("lastUsed").indexDesc(null, false).getProperty();
    entry.addDateProperty("lastUpdateDate").index();
    Property categoryId = entry.addLongProperty("categoryId").index().getProperty();
    entry.addToOne(category, categoryId);

    ToMany categoryToEntries = category.addToMany(entry, categoryId);
    categoryToEntries.setName("entries");
    categoryToEntries.orderDesc(lastUsed);
}
 
开发者ID:cloud-emoticon,项目名称:SmallCloudEmoji,代码行数:35,代码来源:AppDaoGenerator.java

示例6: createToMany

import de.greenrobot.daogenerator.ToMany; //导入方法依赖的package包/类
protected void createToMany() {
    Entity toManyTargetEntity = schema.addEntity("ToManyTargetEntity");
    Property toManyIdProperty = toManyTargetEntity.addLongProperty("toManyId").getProperty();
    Property toManyIdDescProperty = toManyTargetEntity.addLongProperty("toManyIdDesc").getProperty();
    Property targetIdProperty = toManyTargetEntity.addIdProperty().getProperty();
    Property targetJoinProperty = toManyTargetEntity.addStringProperty("targetJoinProperty").getProperty();

    Entity toManyEntity = schema.addEntity("ToManyEntity");
    Property sourceIdProperty = toManyEntity.addIdProperty().getProperty();
    Property sourceJoinProperty = toManyEntity.addStringProperty("sourceJoinProperty").getProperty();

    ToMany toMany = toManyEntity.addToMany(toManyTargetEntity, toManyIdProperty);
    toMany.orderAsc(targetIdProperty);

    ToMany toManyDesc = toManyEntity.addToMany(toManyTargetEntity, toManyIdDescProperty);
    toManyDesc.setName("toManyDescList");
    toManyDesc.orderDesc(targetIdProperty);

    ToMany toManyByJoinProperty = toManyEntity
            .addToMany(sourceJoinProperty, toManyTargetEntity, targetJoinProperty);
    toManyByJoinProperty.setName("toManyByJoinProperty");
    toManyByJoinProperty.orderAsc(targetIdProperty);

    Property[] sourceProperties = { sourceIdProperty, sourceJoinProperty };
    Property[] targetProperties = { toManyIdProperty, targetJoinProperty };
    ToMany toManyJoinTwo = toManyEntity.addToMany(sourceProperties, toManyTargetEntity, targetProperties);
    toManyJoinTwo.setName("toManyJoinTwo");
    toManyJoinTwo.orderDesc(targetJoinProperty);
    toManyJoinTwo.orderDesc(targetIdProperty);
}
 
开发者ID:itsmechlark,项目名称:greendao-cipher,代码行数:31,代码来源:TestDaoGenerator.java

示例7: main

import de.greenrobot.daogenerator.ToMany; //导入方法依赖的package包/类
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/");
}
 
开发者ID:Kamshak,项目名称:BrainPhaser,代码行数:50,代码来源:BrainphaserDaoGenerator.java

示例8: addArticleType

import de.greenrobot.daogenerator.ToMany; //导入方法依赖的package包/类
private static void addArticleType(Schema schema){

            Entity  type=schema.addEntity("ArticleType");
            type.addIdProperty().autoincrement();
            type.addStringProperty("name");

            Entity article =schema.addEntity("ArticleItemCache");
            article.addIdProperty().autoincrement();
            article.addStringProperty("title");
            article.addStringProperty("url");

            Property typeId=article.addLongProperty("typeId").getProperty();

            article.addToOne(type,typeId);

            ToMany toMany=type.addToMany(article,typeId);
            toMany.setName("articles");

    }
 
开发者ID:Thereisnospon,项目名称:BlogReader,代码行数:20,代码来源:DataDaoGenerator.java

示例9: setSchemaProperties

import de.greenrobot.daogenerator.ToMany; //导入方法依赖的package包/类
@Override
public void setSchemaProperties() {
    Entity dailyMeal = mSchema.addEntity(SCHEMA_KEY);
    dailyMeal.addIdProperty().autoincrement();
    Property dailyMealEatenOn = dailyMeal.addLongProperty(EATEN_ON).notNull().unique().index().getProperty();
    dailyMeal.addIntProperty(GLASSES_WATER);
    dailyMeal.addLongProperty(UPDATED_AT);
    dailyMeal.addStringProperty(REFLECTION);

    //Create the meal entity
    Entity meal = mSchema.addEntity(SCHEMA_MEAL_KEY);
    Property mealOrderProperty = meal.addIdProperty().autoincrement().getProperty();
    meal.addStringProperty(MEAL_SIZE);
    Property mealType = meal.addStringProperty(MEAL_TYPE).getProperty();
    meal.addLongProperty(MEAL_UPDATED_AT);
    meal.addIntProperty(MEAL_HEALTHINESS);
    meal.addStringProperty(MEAL_PHOTO_URL);
    Property mealOwnerEatenOnProperty = meal.addLongProperty(EATEN_ON).notNull().index().getProperty();
    Property mealPhotoProperty = meal.addLongProperty(MEAL_PHOTO_ID).getProperty();

    //Add a unique index on MealType + Meal eatenOn
    Index indexUniqueMealType = new Index();
    indexUniqueMealType.addProperty(mealType);
    indexUniqueMealType.addProperty(mealOwnerEatenOnProperty);
    indexUniqueMealType.makeUnique();
    meal.addIndex(indexUniqueMealType);

    //Set the property that the daily meal has meals
    ToMany dailyMealToMealsEatenOn = dailyMeal.addToMany(dailyMealEatenOn, meal, mealOwnerEatenOnProperty);
    dailyMealToMealsEatenOn.setName(DAILYMEAL_TO_MEAL_RELATION_KEY);
    dailyMealToMealsEatenOn.orderDesc(mealOrderProperty);

    //Create the mealItem entity
    Entity mealItem = mSchema.addEntity(SCHEMA_MEAL_ITEM_KEY);
    Property mealItemOrderProperty = mealItem.addIdProperty().autoincrement().getProperty();
    Property mealItemItem = mealItem.addStringProperty(MEAL_ITEM).notNull().getProperty();
    Property mealItemOwnerProperty = mealItem.addLongProperty(OWNER_MEAL_ID).notNull().getProperty();

    //Add a unique index on mealItem + mealId
    Index indexUniqueMealItem = new Index();
    indexUniqueMealItem.addProperty(mealItemItem);
    indexUniqueMealItem.addProperty(mealItemOwnerProperty);
    indexUniqueMealItem.makeUnique();
    mealItem.addIndex(indexUniqueMealItem);

    //Set the property that the meal has meal items
    ToMany mealItemToMeals = meal.addToMany(mealItem, mealItemOwnerProperty);
    mealItemToMeals.setName(MEAL_TO_ITEMS_RELATION_KEY);
    mealItemToMeals.orderDesc(mealItemOrderProperty);
}
 
开发者ID:olivierg13,项目名称:GreenDao-vs-Realm,代码行数:51,代码来源:DailyMealSchema.java


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