本文整理汇总了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");
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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);
}
示例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");
}
示例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())
);
}
}
}
示例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);
}
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}