/** Adds a to-many relationship; the target entity is joined to the PK property of this entity (typically the ID). */ public ToMany addToMany(Entity target, Property targetProperty) { Property[] targetProperties = {targetProperty}; return addToMany(null, target, targetProperties); }
/** Adds a to-many relationship; the target entity is joined to the PK property of this entity (typically the ID). */ public ToMany addToMany(Entity target, Property targetProperty) { Property[] targetProperties = {targetProperty}; return addToMany(null, target, targetProperties); }
/** * Add a to-many relationship; the target entity is joined using the given target property (of the target entity) * and given source property (of this entity). */ public ToMany addToMany(Property sourceProperty, Entity target, Property targetProperty) { Property[] sourceProperties = {sourceProperty}; Property[] targetProperties = {targetProperty}; return addToMany(sourceProperties, target, targetProperties); }
/** * Add a to-many relationship; the target entity is joined using the given target property (of the target entity) * and given source property (of this entity). */ public ToMany addToMany(Property sourceProperty, Entity target, Property targetProperty) { Property[] sourceProperties = {sourceProperty}; Property[] targetProperties = {targetProperty}; return addToMany(sourceProperties, target, targetProperties); }
/** * Convenience method for {@link Entity#addToMany(Entity, Property)} with a subsequent call to {@link * ToMany#setName(String)}. */ public ToMany addToMany(Entity target, Property targetProperty, String name) { ToMany toMany = addToMany(target, targetProperty); toMany.setName(name); return toMany; }
/** * Convenience method for {@link Entity#addToMany(Entity, Property)} with a subsequent call to {@link * ToMany#setName(String)}. */ public ToMany addToMany(Entity target, Property targetProperty, String name) { ToMany toMany = addToMany(target, targetProperty); toMany.setName(name); return toMany; }
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(); } }
@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); }