當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。