當前位置: 首頁>>代碼示例>>Java>>正文


Java Entity類代碼示例

本文整理匯總了Java中de.greenrobot.daogenerator.Entity的典型用法代碼示例。如果您正苦於以下問題:Java Entity類的具體用法?Java Entity怎麽用?Java Entity使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Entity類屬於de.greenrobot.daogenerator包,在下文中一共展示了Entity類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addNote

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
/**
 * @param schema
 */
private static void addNote(Schema schema) {
    Entity note = schema.addEntity("Note");
    note.addIdProperty();
    note.addIntProperty("note_id");//筆記編號
    note.addStringProperty("guid");//用戶ID
    note.addIntProperty("status");//狀態
    note.addStringProperty("tag");//類型
    note.addStringProperty("label");//標題
    note.addStringProperty("content");//內容
    note.addStringProperty("imagePath");//圖片目錄
    note.addStringProperty("voicePath");//聲音目錄
    note.addLongProperty("createTime");//創建時間
    note.addLongProperty("lastOprTime");//最後修改時間

    Entity tag = schema.addEntity("Tag");//標簽類型
    tag .addIdProperty();
    tag.addStringProperty("tag");
    tag.addIntProperty("size");
}
 
開發者ID:lpy19930103,項目名稱:MinimalismJotter,代碼行數:23,代碼來源:NoteDaoGenerator.java

示例2: addDepartment

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
private static void addDepartment(Schema schema){
    Entity department = schema.addEntity("DepartmentEntity");
    department.setTableName("Department");
    department.setClassNameDao("DepartmentDao");
    department.setJavaPackage(entityPath);

    department.addIdProperty().autoincrement();
    department.addIntProperty("departId").unique().notNull().index();
    department.addStringProperty("departName").unique().notNull().index();
    department.addIntProperty("priority").notNull();
    department.addIntProperty("status").notNull();

    department.addIntProperty("created").notNull();
    department.addIntProperty("updated").notNull();

    department.setHasKeepSections(true);
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:18,代碼來源:GreenDaoGenerator.java

示例3: addGroupInfo

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
private static void addGroupInfo(Schema schema) {
    Entity groupInfo = schema.addEntity("GroupEntity");
    groupInfo.setTableName("GroupInfo");
    groupInfo.setClassNameDao("GroupDao");
    groupInfo.setJavaPackage(entityPath);

    groupInfo.addIdProperty().autoincrement();
    groupInfo.addIntProperty("peerId").unique().notNull();
    groupInfo.addIntProperty("groupType").notNull();
    groupInfo.addStringProperty("mainName").notNull();
    groupInfo.addStringProperty("avatar").notNull();
    groupInfo.addIntProperty("creatorId").notNull();
    groupInfo.addIntProperty("userCnt").notNull();

    groupInfo.addStringProperty("userList").notNull();
    groupInfo.addIntProperty("version").notNull();
    groupInfo.addIntProperty("status").notNull();
    groupInfo.addIntProperty("created").notNull();
    groupInfo.addIntProperty("updated").notNull();

    groupInfo.setHasKeepSections(true);
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:23,代碼來源:GreenDaoGenerator.java

示例4: addSessionInfo

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
private static void addSessionInfo(Schema schema){
    Entity sessionInfo = schema.addEntity("SessionEntity");
    sessionInfo.setTableName("Session");
    sessionInfo.setClassNameDao("SessionDao");
    sessionInfo.setJavaPackage(entityPath);

    //point to userId/groupId need sessionType 區分
    sessionInfo.addIdProperty().autoincrement();
    sessionInfo.addStringProperty("sessionKey").unique().notNull(); //.unique()
    sessionInfo.addIntProperty("peerId").notNull();
    sessionInfo.addIntProperty("peerType").notNull();

    sessionInfo.addIntProperty("latestMsgType").notNull();
    sessionInfo.addIntProperty("latestMsgId").notNull();
    sessionInfo.addStringProperty("latestMsgData").notNull();

    sessionInfo.addIntProperty("talkId").notNull();
    sessionInfo.addIntProperty("created").notNull();
    sessionInfo.addIntProperty("updated").notNull();

    sessionInfo.setHasKeepSections(true);
}
 
開發者ID:ccfish86,項目名稱:sctalk,代碼行數:23,代碼來源:GreenDaoGenerator.java

示例5: addDialog

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
private static Entity addDialog(Schema schema){
    Entity dialog = schema.addEntity("Dialog");
    dialog.addIdProperty().primaryKey().autoincrement();
    dialog.addStringProperty("dialog_id");
    dialog.addStringProperty("created_at");
    dialog.addStringProperty("updated_at");
    dialog.addStringProperty("last_message");
    dialog.addLongProperty("last_message_date_sent");
    dialog.addIntProperty("last_message_user_id");
    dialog.addStringProperty("name");
    dialog.addStringProperty("photo");
    dialog.addStringProperty("occupants_ids");
    dialog.addIntProperty("type");
    dialog.addIntProperty("unread_messages_count");
    dialog.addStringProperty("xmpp_room_jid");
    return dialog;
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:18,代碼來源:InitDao.java

示例6: addMessage

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
private static Entity addMessage(Schema schema){
    Entity message = schema.addEntity("Message");
    message.addIdProperty().primaryKey().autoincrement();
    message.addStringProperty("message_id");
    message.addStringProperty("created_at");
    message.addStringProperty("updated_at");
    message.addStringProperty("attachments");
    message.addStringProperty("read_ids");
    message.addStringProperty("delivered_ids");
    message.addStringProperty("chat_dialog_id");
    message.addLongProperty("date_sent");
    message.addStringProperty("message");
    message.addStringProperty("recipient_id");
    message.addIntProperty("sender_id");
    message.addIntProperty("read");
    return message;
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:18,代碼來源:InitDao.java

示例7: addUser

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
private static Entity addUser(Schema schema){
    Entity user = schema.addEntity("User");
    user.addIdProperty().primaryKey().autoincrement();
    user.addIntProperty("user_id");
    user.addStringProperty("full_name");
    user.addStringProperty("email");
    user.addStringProperty("login");
    user.addStringProperty("phone");
    user.addStringProperty("website");
    user.addStringProperty("created_at");
    user.addStringProperty("updated_at");
    user.addStringProperty("last_request_at");
    user.addStringProperty("external_user_id");
    user.addLongProperty("facebook_id");
    user.addStringProperty("twitter_id");
    user.addIntProperty("twitter_digits_id");
    user.addIntProperty("blob_id");
    user.addStringProperty("custom_data");
    user.addStringProperty("user_tags");
    return user;
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:22,代碼來源:InitDao.java

示例8: addMusic

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
private static void addMusic(Schema schema) {
    Entity music = schema.addEntity("Music");
    music.addIdProperty();
    music.addStringProperty("mediaType");//eg: mp3
    music.addStringProperty("musicType");//eg:兒歌,英文
    music.addStringProperty("url");
    music.addStringProperty("singer");
    music.addStringProperty("author");
    music.addStringProperty("poster_url");//海報url
    music.addStringProperty("lyrics_url");//歌詞url
    music.addStringProperty("name");
    music.addLongProperty("size");
    music.addStringProperty("albums");//專輯
    music.addIntProperty("quality");
    music.setSuperclass("cn.bmob.v3.BmobObject");
}
 
開發者ID:DroidKOF,項目名稱:pineapple,代碼行數:17,代碼來源:PineappleGenerator.java

示例9: 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

示例10: addNote

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
/**
 * @param schema
 */
private static void addNote(Schema schema) {
    // 一個實體(類)就關聯到數據庫中的一張表,此處表名為「Note」(既類名)
    Entity note = schema.addEntity("Note");
    // 你也可以重新給表命名
    // note.setTableName("NODE");

    // greenDAO 會自動根據實體類的屬性值來創建表字段,並賦予默認值
    // 接下來你便可以設置表中的字段:
    note.addIdProperty();
    note.addStringProperty("text").notNull();
    // 與在 Java 中使用駝峰命名法不同,默認數據庫中的命名是使用大寫和下劃線來分割單詞的。
    // For example, a property called “creationDate” will become a database column “CREATION_DATE”.
    note.addStringProperty("comment");
    note.addDateProperty("date");
}
 
開發者ID:Thereisnospon,項目名稱:BlogReader,代碼行數:19,代碼來源:DataDaoGenerator.java

示例11: handleRenamedEntities

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
private void handleRenamedEntities(Schema from, Schema to, MethodSpec.Builder applyMigrationBuilder) {

        final EntityRenameDesc entityRenameDesc = resolveEntityRenameDescription(from, to, mEntityRenameDescList);
        if (entityRenameDesc != null) {

            final Map<Entity, Entity> renamedEntities = Utils.getRenamed(from, to, entityRenameDesc);
            if (!renamedEntities.isEmpty()) {
                System.out.println(String.format(Locale.US, "Rename %d entities when going from v%d to v%d", renamedEntities.size(), from.getVersion(), to.getVersion()));
            }
            for (Entity entity : renamedEntities.keySet()) {
                applyMigrationBuilder.addStatement(
                        "$L.execSQL($S)",
                        mDbParameterSpec.name,
                        String.format(Locale.US, "ALTER TABLE %s RENAME TO %s", entity.getTableName(), renamedEntities.get(entity).getTableName())
                );
            }

        }
    }
 
開發者ID:vinaysshenoy,項目名稱:poirot,代碼行數:20,代碼來源:Migrations.java

示例12: handleAddedEntities

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
private void handleAddedEntities(Schema from, Schema to, MethodSpec.Builder applyMigrationBuilder) {

        final List<Entity> addedEntities = Utils.getAdded(from, to, resolveEntityRenameDescription(from, to, mEntityRenameDescList));
        if (!addedEntities.isEmpty()) {
            System.out.println(String.format(Locale.US, "Added %d entities when going from v%d to v%d", addedEntities.size(), from.getVersion(), to.getVersion()));
        }
        if (addedEntities.size() > 0) {
            for (Entity addedEntity : addedEntities) {

                applyMigrationBuilder.addStatement("$L.execSQL($S)",
                        mDbParameterSpec.name,
                        String.format(Locale.US, "CREATE TABLE IF NOT EXISTS \"%s\" (%s)", addedEntity.getTableName(), Utils.getPropertySqlDef(addedEntity.getPkProperty()))
                );
                addColumns(addedEntity, Utils.entityPropertiesWithoutPrimaryKey(addedEntity), applyMigrationBuilder);
                addIndexes(addedEntity, addedEntity.getIndexes(), applyMigrationBuilder);
            }
        }
    }
 
開發者ID:vinaysshenoy,項目名稱:poirot,代碼行數:19,代碼來源:Migrations.java

示例13: getAddedIndexes

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
/**
 * Get a list of the indexes that were added from going from one entity to the other
 *
 * @param prev The entity from which we are migrating
 * @param cur  The entity to which we are migrating
 * @return The list of added indexes
 */
public static List<Index> getAddedIndexes(Entity prev, Entity cur) {

    final AbstractList<String> prevIndexNameList = indexNameList(prev);
    final AbstractList<String> curIndexNameList = indexNameList(cur);

    //Remove all indexes from the current list that are present in the older list
    curIndexNameList.removeAll(prevIndexNameList);
    if (curIndexNameList.size() > 0) {
        //We have entities that have been added
        final Map<String, Index> indexMap = indexMapFromEntity(cur);
        final Iterator<Map.Entry<String, Index>> iterator = indexMap.entrySet().iterator();
        Map.Entry<String, Index> next;
        while (iterator.hasNext()) {
            next = iterator.next();
            if (!curIndexNameList.contains(next.getKey())) {
                iterator.remove();
            }
        }
        return new ArrayList<>(indexMap.values());
    } else {
        return Collections.emptyList();
    }
}
 
開發者ID:vinaysshenoy,項目名稱:poirot,代碼行數:31,代碼來源:Utils.java

示例14: getRemovedIndexes

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
/**
 * Get a list of the indexes that were removed from going from one entity to the other
 *
 * @param prev The entity from which we are migrating
 * @param cur  The entity to which we are migrating
 * @return The list of removed indexes
 */
public static List<Index> getRemovedIndexes(Entity prev, Entity cur) {

    final AbstractList<String> prevIndexNameList = indexNameList(prev);
    final AbstractList<String> curIndexNameList = indexNameList(cur);

    //Remove all indexes from the current list that are present in the older list
    prevIndexNameList.removeAll(curIndexNameList);
    if (prevIndexNameList.size() > 0) {
        //We have entities that have been added
        final Map<String, Index> indexMap = indexMapFromEntity(prev);
        final Iterator<Map.Entry<String, Index>> iterator = indexMap.entrySet().iterator();
        Map.Entry<String, Index> next;
        while (iterator.hasNext()) {
            next = iterator.next();
            if (!prevIndexNameList.contains(next.getKey())) {
                iterator.remove();
            }
        }
        return new ArrayList<>(indexMap.values());
    } else {
        return Collections.emptyList();
    }
}
 
開發者ID:vinaysshenoy,項目名稱:poirot,代碼行數:31,代碼來源:Utils.java

示例15: getAddedProperties

import de.greenrobot.daogenerator.Entity; //導入依賴的package包/類
/**
 * Get a list of the properties that were added when going from one entity to the other
 *
 * @param prev The entity from which we are migrating
 * @param cur  The entity to which we are migrating
 * @return The list of added properties
 */
public static List<Property> getAddedProperties(Entity prev, Entity cur) {

    final AbstractList<String> prevPropertyNameList = propertyNameList(prev);
    final AbstractList<String> curPropertyNameList = propertyNameList(cur);

    //Remove all properties from the current list that are present in the older list
    curPropertyNameList.removeAll(prevPropertyNameList);
    if (curPropertyNameList.size() > 0) {
        //We have entities that have been added
        final Map<String, Property> propertyMap = propertyMapFromEntity(cur);
        final Iterator<Map.Entry<String, Property>> iterator = propertyMap.entrySet().iterator();
        Map.Entry<String, Property> next;
        while (iterator.hasNext()) {
            next = iterator.next();
            if (!curPropertyNameList.contains(next.getKey())) {
                iterator.remove();
            }
        }
        return new ArrayList<>(propertyMap.values());
    } else {
        return Collections.emptyList();
    }
}
 
開發者ID:vinaysshenoy,項目名稱:poirot,代碼行數:31,代碼來源:Utils.java


注:本文中的de.greenrobot.daogenerator.Entity類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。