本文整理汇总了Java中de.greenrobot.daogenerator.DaoGenerator类的典型用法代码示例。如果您正苦于以下问题:Java DaoGenerator类的具体用法?Java DaoGenerator怎么用?Java DaoGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DaoGenerator类属于de.greenrobot.daogenerator包,在下文中一共展示了DaoGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void main(String args[]) throws Exception{
// System.out.print("Generating... " + args[0].toString());
Schema schema = new Schema(54,"com.braunster.chatsdk.dao");
schema.enableKeepSectionsByDefault();
addUser(schema);
addMessages(schema);
addThread(schema);
addLinkedAccounts(schema);
addContactLink(schema);
addUserThreadLink(schema);
addFollower(schema);
setBidirectionalRelationships();
// setImplementation();
setSuperClass();
new DaoGenerator().generateAll(schema, outputDir);
}
示例2: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// 正如你所见的,你创建了一个用于添加实体(Entity)的模式(Schema)对象。
// 两个参数分别代表:数据库版本号与自动生成代码的包路径。
Schema schema = new Schema(2, "thereisnospon.com.blogreader.database");
// 当然,如果你愿意,你也可以分别指定生成的 Bean 与 DAO 类所在的目录,只要如下所示:
// Schema schema = new Schema(1, "me.itangqi.bean");
// schema.setDefaultJavaPackageDao("me.itangqi.dao");
// 模式(Schema)同时也拥有两个默认的 flags,分别用来标示 entity 是否是 activie 以及是否使用 keep sections。
// schema2.enableActiveEntitiesByDefault();
// schema2.enableKeepSectionsByDefault();
// 一旦你拥有了一个 Schema 对象后,你便可以使用它添加实体(Entities)了。
addHtmlCache(schema);
addArticleType(schema);
// 最后我们将使用 DAOGenerator 类的 generateAll() 方法自动生成代码,此处你需要根据自己的情况更改输出目录(既之前创建的 java-gen)。
// 其实,输出目录的路径可以在 build.gradle 中设置,有兴趣的朋友可以自行搜索,这里就不再详解。
new DaoGenerator().generateAll(schema, "./app/src/main/java/");
}
示例3: testMinimalSchema
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的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());
}
示例4: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Schema schema = new Schema(13, MAIN_PACKAGE + ".entities");
addActivityDescription(schema);
Entity userAttributes = addUserAttributes(schema);
Entity user = addUserInfo(schema, userAttributes);
Entity deviceAttributes = addDeviceAttributes(schema);
Entity device = addDevice(schema, deviceAttributes);
addMiBandActivitySample(schema, user, device);
addPebbleHealthActivitySample(schema, user, device);
addPebbleHealthActivityKindOverlay(schema, user, device);
addPebbleMisfitActivitySample(schema, user, device);
addPebbleMorpheuzActivitySample(schema, user, device);
new DaoGenerator().generateAll(schema, "app/src/main/java");
}
示例5: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的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();
}
}
示例6: generate
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void generate() throws Exception {
Utilities.deleteContents(new File(DELETE_DIR));
File outDir = new File(OUT_DIR);
outDir.delete();
outDir.mkdirs();
Schema schema = new Schema(VERSION, PACKAGE);
addDownloads(schema);
addDownloadLabel(schema);
addDownloadDirname(schema);
addHistoryInfo(schema);
addQuickSearch(schema);
addLocalFavorites(schema);
addBookmarks(schema);
addFilter(schema);
new DaoGenerator().generateAll(schema, OUT_DIR);
adjustDownloadInfo();
adjustHistoryInfo();
adjustQuickSearch();
adjustLocalFavoriteInfo();
adjustBookmarkInfo();
adjustFilter();
}
示例7: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
Schema schema = new Schema(3, "greendao");
Entity verses = schema.addEntity("Verse");
verses.setTableName("verses");
verses.addIdProperty().columnName("_rowid_");
verses.addIntProperty("chapter");
verses.addIntProperty("verse");
verses.addStringProperty("book");
verses.addStringProperty("header");
verses.addStringProperty("subheader");
verses.addStringProperty("text");
Entity books = schema.addEntity("Book");
books.addLongProperty("indice").primaryKey().unique();
books.setTableName("books");
books.addStringProperty("name");
books.addStringProperty("abbreviation");
books.addStringProperty("testament");
new DaoGenerator().generateAll(schema, args[0]);
}
示例8: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的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");
}
示例9: testMinimalSchema
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
@Test
public void testMinimalSchema() throws Exception {
Schema schema = new Schema(1, "de.greenrobot.testdao");
Entity adressTable = schema.addEntity("Adresse");
Property idProperty = adressTable.addIdProperty().getProperty();
adressTable.addIntProperty("count").index();
adressTable.addIntProperty("dummy").notNull();
assertEquals(1, schema.getEntities().size());
assertEquals(3, adressTable.getProperties().size());
File daoFile = new File("test-out/de/greenrobot/testdao/" + adressTable.getClassName() + "Dao.java");
daoFile.delete();
assertFalse(daoFile.exists());
new DaoGenerator().generateAll(schema, "test-out");
assertEquals("PRIMARY KEY", idProperty.getConstraints());
assertTrue(daoFile.toString(), daoFile.exists());
}
示例10: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void main(String[] args) {
Schema schema = new Schema(DB_VERSION, PACKAGE);
Entity user = schema.addEntity(USER_ENTITY);
Property userPk = addCommonColumns(user);
Entity message = schema.addEntity(MESSAGE_ENTITY);
message.addIdProperty().autoincrement();
message.addStringProperty(CONTENT);
message.addLongProperty(CLIENT_ID);
message.addIntProperty(CREATED_AT);
message.addDoubleProperty(SORTED_BY);
message.addLongProperty(COMMAND_ID).index();
message.addLongProperty(SENDER_ID).notNull();
message.addLongProperty(CHANNEL_ID).notNull();
// One-to-many relationship
message.addToMany(user, userPk, READERS);
try {
new DaoGenerator().generateAll(schema, "../ORM-Benchmark/src/");
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Schema schema = new Schema(DB_VERSION, "com.gmobile.sqliteeditor.orm.dao.model");
schema.setDefaultJavaPackageDao("com.gmobile.sqliteeditor.orm.dao.base");
addAppData(schema);
addHistoryRecord(schema);
addMineRecord(schema);
new DaoGenerator().generateAll(schema, getCurrentProjectPath() + "/app/src/main/java/");
}
示例12: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Schema schema = new Schema(1, "com.lipy.mylibrary.dao.core");
schema.enableKeepSectionsByDefault();
addPedometer(schema);
// new DaoGenerator().generateAll(schema, "E:/project/AndroidPedometer/mylibrary/src/main/java/");
new DaoGenerator().generateAll(schema, "/Users/lipy/Documents/AndroidPedometer/mylibrary/src/main/java/");
}
示例13: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
int dbVersion = 12;
Schema schema = new Schema(dbVersion, "com.mogujie.tt.DB.dao");
schema.enableKeepSectionsByDefault();
addDepartment(schema);
addUserInfo(schema);
addGroupInfo(schema);
addMessage(schema);
addSessionInfo(schema);
// todo 绝对路径,根据自己的路径设定, 例子如下
String path = "/Users/yingmu/software/IM/TT/ttandroidclientnew/app/src/main/java";
new DaoGenerator().generateAll(schema, path);
}
示例14: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Schema schema = new Schema(1000, "pineapple.bd.com.pineapple.db");
//注释内容为范例,生成的时候别打开!
// addNote(schema);
//addCustomerOrder(schema);
addUser(schema);
addUserAuth(schema);
addMusic(schema);
//用绝对路径找!
new DaoGenerator().generateAll(schema, "app/src/main/java");
}
示例15: main
import de.greenrobot.daogenerator.DaoGenerator; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Schema schema = new Schema(1, "com.fangxu.dota2helper.greendao");
addNews(schema);
addStrategy(schema);
addUpdate(schema);
addVideo(schema);
addHistoryVideo(schema);
new DaoGenerator().generateAll(schema, "../Dota2Helper/app/src/main/java-gen");
}