本文整理汇总了Java中de.greenrobot.daogenerator.Schema.addEntity方法的典型用法代码示例。如果您正苦于以下问题:Java Schema.addEntity方法的具体用法?Java Schema.addEntity怎么用?Java Schema.addEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.greenrobot.daogenerator.Schema
的用法示例。
在下文中一共展示了Schema.addEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addGroupInfo
import de.greenrobot.daogenerator.Schema; //导入方法依赖的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);
}
示例2: addThread
import de.greenrobot.daogenerator.Schema; //导入方法依赖的package包/类
private static Property addThread(Schema schema) {
Property threadId;
thread = schema.addEntity(EntityProperties.BThread);
thread.addIdProperty();
threadId = thread.addStringProperty(EntityProperties.EntityID).getProperty();
thread.addDateProperty(EntityProperties.CreationDate);
thread.addBooleanProperty(EntityProperties.HasUnreadMessaged);
thread.addBooleanProperty(EntityProperties.BDeleted);
thread.addStringProperty(EntityProperties.Name);
thread.addDateProperty(EntityProperties.LastMessageAdded);
thread.addIntProperty(EntityProperties.Type);
thread.addStringProperty(EntityProperties.CreatorEntityID);
thread.addStringProperty(EntityProperties.BThreadImageUrl);
thread.addStringProperty(EntityProperties.RootKey).columnName(EntityProperties.C_RootKey);
thread.addStringProperty(EntityProperties.ApiKey).columnName(EntityProperties.C_ApiKey);
Property threadPropCreator = thread.addLongProperty(EntityProperties.CreatorID).getProperty();
ToOne threadToOneCreator = thread.addToOne(user, threadPropCreator);
threadToOneCreator.setName(EntityProperties.Creator);
return threadId;
}
示例3: addMessages
import de.greenrobot.daogenerator.Schema; //导入方法依赖的package包/类
private static Property addMessages(Schema schema){
Property messageId;
message = schema.addEntity(EntityProperties.BMessage);
message.addIdProperty();
messageId = message.addStringProperty(EntityProperties.EntityID).getProperty();
message.addDateProperty(EntityProperties.Date);
message.addBooleanProperty(EntityProperties.isRead);
message.addStringProperty(EntityProperties.Resource);
message.addStringProperty(EntityProperties.ResourcePath);
message.addStringProperty(EntityProperties.Text);
message.addStringProperty(EntityProperties.ImageDimensions);
message.addIntProperty(EntityProperties.Type);
message.addIntProperty(EntityProperties.Status);
message.addIntProperty(EntityProperties.Delivered);
// The sender ID
Property messagePropSender = message.addLongProperty("Sender").getProperty();
ToOne messageToOneSender = message.addToOne(user, messagePropSender);
messageToOneSender.setName("BUserSender");
return messageId;
}
示例4: addDepartment
import de.greenrobot.daogenerator.Schema; //导入方法依赖的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);
}
示例5: addMessage
import de.greenrobot.daogenerator.Schema; //导入方法依赖的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;
}
示例6: addSessionInfo
import de.greenrobot.daogenerator.Schema; //导入方法依赖的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);
}
示例7: testMinimalSchema
import de.greenrobot.daogenerator.Schema; //导入方法依赖的package包/类
@Test
public void testMinimalSchema() throws Exception {
Schema schema = new Schema(1, "de.greenrobot.testdao");
Entity addressEntity = schema.addEntity("Addresse");
Property idProperty = addressEntity.addIdProperty().getProperty();
addressEntity.addIntProperty("count").index();
addressEntity.addIntProperty("dummy").notNull();
assertEquals(1, schema.getEntities().size());
assertEquals(3, addressEntity.getProperties().size());
File daoFile = new File("test-out/de/greenrobot/testdao/" + addressEntity.getClassName() + "Dao.java");
daoFile.delete();
assertFalse(daoFile.exists());
new DaoGenerator().generateAll(schema, "test-out");
assertEquals("PRIMARY KEY", idProperty.getConstraints());
assertTrue(daoFile.toString(), daoFile.exists());
}
示例8: addNote
import de.greenrobot.daogenerator.Schema; //导入方法依赖的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");
}
示例9: addHtml
import de.greenrobot.daogenerator.Schema; //导入方法依赖的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);
}
示例10: getTable
import de.greenrobot.daogenerator.Schema; //导入方法依赖的package包/类
public static Entity getTable(Schema schema, Class c){
Entity entity = null;
String table = null;
try {
Field field = c.getDeclaredField("TABLE_NAME");
field.setAccessible(true);
table = (String) field.get(null);
table = table.substring(0,1).toUpperCase() + table.substring(1);
entity = schema.addEntity(table);
} catch (Exception e) {
}
return entity;
}
示例11: addContactLink
import de.greenrobot.daogenerator.Schema; //导入方法依赖的package包/类
private static Property addContactLink(Schema schema) {
Property contactLinkId;
Entity contactLink = schema.addEntity(EntityProperties.ContactLink);
contactLinkId = contactLink.addIdProperty().getProperty();
setManyToMany(contactLink, user, user);
contactLink.setSuperclass("Entity");
return contactLinkId;
}
示例12: addUserThreadLink
import de.greenrobot.daogenerator.Schema; //导入方法依赖的package包/类
private static Property addUserThreadLink(Schema schema){
Property userThreadLinkId;
userThreadLink = schema.addEntity(EntityProperties.UserThreadLink);
userThreadLinkId = userThreadLink.addIdProperty().primaryKey().getProperty();
// Link data for user and thread.
setManyToMany(userThreadLink, user, thread);
return userThreadLinkId;
}
示例13: addUserInfo
import de.greenrobot.daogenerator.Schema; //导入方法依赖的package包/类
private static void addUserInfo(Schema schema) {
Entity userInfo = schema.addEntity("UserEntity");
userInfo.setTableName("UserInfo");
userInfo.setClassNameDao("UserDao");
userInfo.setJavaPackage(entityPath);
userInfo.addIdProperty().autoincrement();
userInfo.addIntProperty("peerId").unique().notNull().index();
userInfo.addIntProperty("gender").notNull();
userInfo.addStringProperty("mainName").notNull();
// 这个可以自动生成pinyin
userInfo.addStringProperty("pinyinName").notNull();
userInfo.addStringProperty("realName").notNull();
userInfo.addStringProperty("avatar").notNull();
userInfo.addStringProperty("phone").notNull();
userInfo.addStringProperty("email").notNull();
userInfo.addIntProperty("departmentId").notNull();
userInfo.addIntProperty("status").notNull();
userInfo.addIntProperty("created").notNull();
userInfo.addIntProperty("updated").notNull();
userInfo.setHasKeepSections(true);
//todo 索引还没有设定
// 一对一 addToOne 的使用
// 支持protobuf
// schema.addProtobufEntity();
}
示例14: addAppData
import de.greenrobot.daogenerator.Schema; //导入方法依赖的package包/类
private static void addAppData(Schema schema) {
Entity tableName = schema.addEntity("AppData");
tableName.addIdProperty().autoincrement();
tableName.addStringProperty("appName");
tableName.addStringProperty("appPackageName").unique();
tableName.addLongProperty("lastModified");
tableName.addIntProperty("isSystem");
}
示例15: addHistoryRecord
import de.greenrobot.daogenerator.Schema; //导入方法依赖的package包/类
private static void addHistoryRecord(Schema schema) {
Entity tableName = schema.addEntity("HistoryData");
tableName.addIdProperty().autoincrement();
tableName.addStringProperty("name");
tableName.addStringProperty("path").unique();
tableName.addStringProperty("appName");
tableName.addStringProperty("appPackageName");
tableName.addLongProperty("size");
tableName.addLongProperty("lastModified");
tableName.addLongProperty("openTime");
}