private static void addNote(Schema schema) { Entity note = schema.addEntity("Note"); note.addIdProperty(); note.addStringProperty("text").notNull(); note.addStringProperty("comment"); note.addDateProperty("date"); }
/** * @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"); } }
private static void addForeCast(Schema schema) { Entity weekForeCast = schema.addEntity("WeekForeCast"); weekForeCast.addStringProperty("areaid"); weekForeCast.addDateProperty("weatherDate"); weekForeCast.addStringProperty("weatherConditionStart"); weekForeCast.addStringProperty("weatherConditionEnd"); weekForeCast.addIntProperty("tempH"); weekForeCast.addIntProperty("tempL"); weekForeCast.addStringProperty("fx"); weekForeCast.addStringProperty("fj"); weekForeCast.addIntProperty("rainPerCent"); }
private static void addRealWeather(Schema schema) { Entity realWeather = schema.addEntity("RealWeather"); realWeather.addStringProperty("areaid"); realWeather.addStringProperty("areaName"); realWeather.addStringProperty("weatherCondition"); realWeather.addStringProperty("fx"); realWeather.addStringProperty("fj"); realWeather.addIntProperty("temp"); realWeather.addIntProperty("feeltemp"); realWeather.addIntProperty("shidu"); realWeather.addStringProperty("sunrise"); realWeather.addStringProperty("sundown"); realWeather.addDateProperty("lastUpdate"); }
@SuppressWarnings("unused") 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); }
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); }