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


Java Entity.addToOne方法代码示例

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


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

示例1: addCustomerOrder

import de.greenrobot.daogenerator.Entity; //导入方法依赖的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: addHtml

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

示例3: addMeal

import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
private static void addMeal(Schema schema, Entity food) {
    Entity meal = schema.addEntity("MealEntity");
    meal.setSuperclass("MealEntityBase");
    meal.addIdProperty().autoincrement().primaryKey();
    meal.addDateProperty("date").notNull();
    meal.addIntProperty("mealtime").notNull();
    meal.addIntProperty("grams").notNull();
    meal.addDoubleProperty("calories").notNull();
    meal.addDoubleProperty("fats").notNull();
    meal.addDoubleProperty("carbohydrates").notNull();
    meal.addDoubleProperty("proteins").notNull();
    meal.addStringProperty("foodName");

    Property foodId = meal.addLongProperty("foodId").getProperty();
    meal.addToOne(food, foodId);
}
 
开发者ID:andreshj87,项目名称:CleanFit,代码行数:17,代码来源:GreenDAOGenerator.java

示例4: main

import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:Raizlabs,项目名称:AndroidDatabaseLibraryComparison,代码行数:24,代码来源:Generator.java

示例5: addAddress

import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
private Entity addAddress(Entity user) {
    Entity address = this.getSchema().addEntity("Address");

    address.addIdProperty();
    address.addIntProperty("number").notNull();
    address.addStringProperty("street").notNull();
    address.addStringProperty("zipCode").notNull();
    address.addStringProperty("city").notNull();
    address.addStringProperty("country").notNull();

    Property userProperty = address.addLongProperty("userId").getProperty();
    address.addToOne(user, userProperty, "user");
    user.addToMany(address, userProperty, "addresses");

    return address;
}
 
开发者ID:Gorcyn,项目名称:GreendaoSample,代码行数:17,代码来源:Version1.java

示例6: addCustomerOrder

import de.greenrobot.daogenerator.Entity; //导入方法依赖的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

示例7: main

import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Schema schema = new Schema(3, "br.com.ricardolonga.mercadinho");

    Entity categoria = schema.addEntity("Categoria");
    categoria.addIdProperty().autoincrement();
    categoria.addStringProperty("nome").notNull();
    categoria.implementsSerializable();

    Entity item = schema.addEntity("Item");
    item.addIdProperty().autoincrement();
    item.addStringProperty("nome").notNull();
    item.addIntProperty("quantidade");
    item.addDoubleProperty("valorUnitario");
    item.addDoubleProperty("valorTotal");
    item.implementsSerializable();
    Property idCategoria = item.addLongProperty("idCategoria").notNull().getProperty();

    item.addToOne(categoria, idCategoria);
    categoria.addToMany(item, idCategoria, "itens");

    new DaoGenerator().generateAll(schema, "../mercadinho/src-gen");
}
 
开发者ID:ricardolonga,项目名称:mercadinho-generator,代码行数:23,代码来源:MercadinhoGenerator.java

示例8: setBidirectionalToMany

import de.greenrobot.daogenerator.Entity; //导入方法依赖的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

示例9: createV2Schema

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

        //Define entities
        final Entity companyEntity = v2.addEntity("Company");
        companyEntity.addIdProperty().autoincrement();
        companyEntity.addStringProperty("companyCode").notNull().unique().index();
        companyEntity.addStringProperty("name").notNull();
        companyEntity.addStringProperty("address");
        companyEntity.addDateProperty("incorporationDate");

        final Entity functionEntity = v2.addEntity("Function");
        functionEntity.addIdProperty().autoincrement();
        functionEntity.addStringProperty("functionCode").notNull().unique();
        functionEntity.addStringProperty("name").notNull();

        final Entity employeeEntity = v2.addEntity("Employee");
        employeeEntity.addIdProperty().autoincrement();
        employeeEntity.addStringProperty("employeeId").notNull().unique();
        employeeEntity.addStringProperty("designation").notNull().index();
        employeeEntity.addStringProperty("name").notNull();
        employeeEntity.addIntProperty("age");
        employeeEntity.addStringProperty("sex").index();
        employeeEntity.addDateProperty("dateOfBirth");
        employeeEntity.addDateProperty("dateOfJoining").notNull();

        final Entity orderEntity = v2.addEntity("Order");
        orderEntity.addIdProperty().autoincrement();
        orderEntity.addStringProperty("orderId").notNull().unique().index();
        orderEntity.addDateProperty("orderDate").notNull();

        //Define relationships
        final Property functionCompanyId = functionEntity.addLongProperty("companyId").notNull().getProperty();
        functionEntity.addToOne(companyEntity, functionCompanyId);
        companyEntity.addToMany(functionEntity, functionCompanyId);

        final Property employeeFunctionId = employeeEntity.addLongProperty("functionId").notNull().getProperty();
        employeeEntity.addToOne(functionEntity, employeeFunctionId);
        functionEntity.addToMany(employeeEntity, employeeFunctionId);
    }
 
开发者ID:vinaysshenoy,项目名称:poirot,代码行数:40,代码来源:Generator.java

示例10: createV1Schema

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

        //Define entities
        final Entity companyEntity = v1.addEntity("Company");
        companyEntity.addIdProperty().autoincrement();
        companyEntity.addStringProperty("companyCode").notNull().unique().index();
        companyEntity.addStringProperty("name").notNull();
        companyEntity.addStringProperty("address");

        final Entity functionEntity = v1.addEntity("Function");
        functionEntity.addIdProperty().autoincrement();
        functionEntity.addStringProperty("functionCode").notNull().unique();
        functionEntity.addStringProperty("name").notNull();

        final Entity employeeEntity = v1.addEntity("Employee");
        employeeEntity.addIdProperty().autoincrement();
        employeeEntity.addStringProperty("employeeId").notNull().unique();
        employeeEntity.addStringProperty("designation").notNull().index();
        employeeEntity.addStringProperty("name").notNull();
        employeeEntity.addIntProperty("age");
        employeeEntity.addStringProperty("sex").index();
        employeeEntity.addDateProperty("dateOfBirth");

        //Define relationships
        final Property functionCompanyId = functionEntity.addLongProperty("companyId").notNull().getProperty();
        functionEntity.addToOne(companyEntity, functionCompanyId);
        companyEntity.addToMany(functionEntity, functionCompanyId);

        final Property employeeFunctionId = employeeEntity.addLongProperty("functionId").notNull().getProperty();
        employeeEntity.addToOne(functionEntity, employeeFunctionId);
        functionEntity.addToMany(employeeEntity, employeeFunctionId);
    }
 
开发者ID:vinaysshenoy,项目名称:poirot,代码行数:33,代码来源:Generator.java

示例11: addPebbleHealthActivityKindOverlay

import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
private static Entity addPebbleHealthActivityKindOverlay(Schema schema, Entity user, Entity device) {
    Entity activityOverlay = addEntity(schema, "PebbleHealthActivityOverlay");

    activityOverlay.addIntProperty("timestampFrom").notNull().primaryKey();
    activityOverlay.addIntProperty("timestampTo").notNull().primaryKey();
    activityOverlay.addIntProperty("rawKind").notNull().primaryKey();
    Property deviceId = activityOverlay.addLongProperty("deviceId").primaryKey().getProperty();
    activityOverlay.addToOne(device, deviceId);

    Property userId = activityOverlay.addLongProperty("userId").getProperty();
    activityOverlay.addToOne(user, userId);
    activityOverlay.addByteArrayProperty("rawPebbleHealthData");

    return activityOverlay;
}
 
开发者ID:scifiswapnil,项目名称:gadgetbridge_artikcloud,代码行数:16,代码来源:GBDaoGenerator.java

示例12: addCommonActivitySampleProperties

import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
private static void addCommonActivitySampleProperties(String superClass, Entity activitySample, Entity user, Entity device) {
    activitySample.setSuperclass(superClass);
    activitySample.addImport(MAIN_PACKAGE + ".devices.SampleProvider");
    activitySample.setJavaDoc(
            "This class represents a sample specific to the device. Values like activity kind or\n" +
                    "intensity, are device specific. Normalized values can be retrieved through the\n" +
                    "corresponding {@link SampleProvider}.");
    activitySample.addIntProperty("timestamp").notNull().primaryKey();
    Property deviceId = activitySample.addLongProperty("deviceId").primaryKey().getProperty();
    activitySample.addToOne(device, deviceId);
    Property userId = activitySample.addLongProperty("userId").getProperty();
    activitySample.addToOne(user, userId);
}
 
开发者ID:scifiswapnil,项目名称:gadgetbridge_artikcloud,代码行数:14,代码来源:GBDaoGenerator.java

示例13: createTables

import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
@Override
public void createTables(Schema schema) {
    Entity users = createUsers(schema);
    Entity userDetails = createUserDetails(schema);

    Property usersIdForUserDetails = userDetails.addLongProperty("usersid").notNull().getProperty();
    Property userDetailsIdForUsers = users.addLongProperty("userdetailsid").notNull().getProperty();

    userDetails.addToOne(users, usersIdForUserDetails, "fkusers");
    users.addToOne(userDetails, userDetailsIdForUsers, "fkuserdetails");
}
 
开发者ID:budioktaviyan,项目名称:greendao-sample,代码行数:12,代码来源:SchemaGenerator.java

示例14: addEntities

import de.greenrobot.daogenerator.Entity; //导入方法依赖的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

示例15: createParentChildRelationship

import de.greenrobot.daogenerator.Entity; //导入方法依赖的package包/类
public static void createParentChildRelationship(Entity parent, String childAttributeName, Entity child,
                                                 String parentAttributeName) throws NullPointerException{

    Property parentOfChildProperty = child.addLongProperty(parentAttributeName).notNull().getProperty();
    child.addToOne(parent, parentOfChildProperty);
    parent.addToMany(child, parentOfChildProperty, childAttributeName);
}
 
开发者ID:unfoldingWord-dev,项目名称:uw-android,代码行数:8,代码来源:DaoHelperMethods.java


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