/** * 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 ToMany addToMany(Property[] sourceProperties, Entity target, Property[] targetProperties) { if (protobuf) { throw new IllegalStateException("Protobuf entities do not support realtions, currently"); } ToMany toMany = new ToMany(schema, this, sourceProperties, target, targetProperties); toManyRelations.add(toMany); target.incomingToManyRelations.add(toMany); return toMany; }
private void init3rdPassRelations() { Set<String> toOneNames = new HashSet<String>(); for (ToOne toOne : toOneRelations) { toOne.init3ndPass(); if (!toOneNames.add(toOne.getName().toLowerCase())) { throw new RuntimeException("Duplicate name for " + toOne); } } Set<String> toManyNames = new HashSet<String>(); for (ToMany toMany : toManyRelations) { toMany.init3ndPass(); Entity targetEntity = toMany.getTargetEntity(); for (Property targetProperty : toMany.getTargetProperties()) { if (!targetEntity.propertiesColumns.contains(targetProperty)) { targetEntity.propertiesColumns.add(targetProperty); } } if (!toManyNames.add(toMany.getName().toLowerCase())) { throw new RuntimeException("Duplicate name for " + toMany); } } }
@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 void init3rdPassRelations() { Set<String> toOneNames = new HashSet<String>(); for (ToOne toOne : toOneRelations) { toOne.init3ndPass(); if (!toOneNames.add(toOne.getName().toLowerCase())) { throw new RuntimeException("Duplicate name for " + toOne); } } Set<String> toManyNames = new HashSet<String>(); for (ToManyBase toMany : toManyRelations) { toMany.init3rdPass(); if (toMany instanceof ToMany) { Entity targetEntity = toMany.getTargetEntity(); for (Property targetProperty : ((ToMany) toMany).getTargetProperties()) { if (!targetEntity.propertiesColumns.contains(targetProperty)) { targetEntity.propertiesColumns.add(targetProperty); } } } if (!toManyNames.add(toMany.getName().toLowerCase())) { throw new RuntimeException("Duplicate name for " + toMany); } } }
private void init3rdPassAdditionalImports() { if (active && !javaPackage.equals(javaPackageDao)) { additionalImportsEntity.add(javaPackageDao + "." + classNameDao); } for (ToOne toOne : toOneRelations) { Entity targetEntity = toOne.getTargetEntity(); checkAdditionalImportsEntityTargetEntity(targetEntity); // For deep loading if (!targetEntity.getJavaPackage().equals(javaPackageDao)) { additionalImportsDao.add(targetEntity.getJavaPackage() + "." + targetEntity.getClassName()); } } for (ToMany toMany : toManyRelations) { Entity targetEntity = toMany.getTargetEntity(); checkAdditionalImportsEntityTargetEntity(targetEntity); } }
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); }
/** * 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 ToMany addToMany(Property[] sourceProperties, Entity target, Property[] targetProperties) { if (protobuf) { throw new IllegalStateException("Protobuf entities do not support relations, currently"); } ToMany toMany = new ToMany(schema, this, sourceProperties, target, targetProperties); toManyRelations.add(toMany); target.incomingToManyRelations.add(toMany); return toMany; }