android greenDAO
来源:互联网 发布:mac电脑怎么打顿号 编辑:程序博客网 时间:2024/05/17 08:14
三个jar包
android项目导入
greendao-1.3.7.jar
java项目导入以下两个包
freemarker-2.3.20.jar
greendao-generator-1.3.0.jar
1:新建一个java项目
ExampleDaoGenerator.java
加入要导的包
三个包下载路径 http://download.csdn.net/detail/argonwu/8233303
package com.daotest;import de.greenrobot.daogenerator.DaoGenerator;import de.greenrobot.daogenerator.Entity;import de.greenrobot.daogenerator.Property;import de.greenrobot.daogenerator.Schema;import de.greenrobot.daogenerator.ToMany;public class ExampleDaoGenerator {public static void main(String[] args) throws Exception {// first parameter for version, <span></span> second for default// generate packageSchema schema = new Schema(1, "com.trustyapp.baseframe.dao");addCompose(schema);/*addNote(schema);addCustomerOrder(schema);addUser(schema);*/// set dao class generate packageschema.setDefaultJavaPackageDao("com.trustyapp.baseframe.dao");// keep custom code blockschema.enableKeepSectionsByDefault();new DaoGenerator().generateAll(schema, "../DAOTest/src");}private static void addNote(Schema schema) {Entity note = schema.addEntity("Note");note.addIdProperty();note.addStringProperty("text").notNull();note.addStringProperty("comment");note.addStringProperty("date");}private static void addCompose(Schema schema){Entity note = schema.addEntity("Compose");note.addIdProperty();note.addStringProperty("eid").notNull();note.addStringProperty("etitle");note.addStringProperty("etype");note.addStringProperty("ebody");note.addDateProperty("edate");}private static void addUser(Schema schema) {Entity user = schema.addEntity("User");user.setTableName("t_user");user.addIdProperty();user.addStringProperty("account").unique();user.addStringProperty("password");user.addDateProperty("birthday");user.addShortProperty("gender");user.addIntProperty("height");user.addFloatProperty("weight");user.addDateProperty("registerTime");user.implementsInterface("Jsonable<User>");}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 keywordorder.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);}}
运行后会在
DAOTest下生成几个dao文件。
到此ok
0 0
- android greenDAO
- android greenDAO
- ANDROID GreenDao 使用例子 Android GreenDAO Simple
- Android Orm框架(GreenDao)
- android greenDao使用
- Android greenDAO入门
- Android studio使用greenDao
- android arm greenDAO
- Android框架 -- GreenDao
- Android GreenDao使用详解
- android 数据库之greendao
- Android必知必会--GreenDao缓存
- Android Studio 导入 GreenDao
- android greenDao(二)
- Android Orm框架(GreenDao)
- Android 的ORM GreenDao
- Android greenDAO使用方法解析
- Android GreenDao浅析
- String split 及 转义字符
- 西安宾利婚车租赁出租车队总管的职责
- C数组和字符串
- MySql SQL语句执行的顺序
- 程序设计之基础与3种学习方法
- android greenDAO
- 调试技巧
- CentOS的软件安装方法rpm和yum
- /dev/tty /dev/ttyS0 /dev/tty0区别
- H264编码原理以及I帧B帧P帧(1)
- 卡通小人的眼睛跟着鼠标动
- Macbook pro retina 上安装Matlab2014b
- android开发视频播放器-----视频播放 Vitamio框架的使用(一)
- H264语法及结构(2)