/** Function to be called before delete */
  private void onPreDelete() {
    List<Association> associations = AssociationFinder.findAssociations(this.getClass());
    for (Association assoc : associations) {

      // Ignore if the class has the ignore on the field
      if (assoc.clazz.getAnnotation(CascadeIgnore.class) == null
          && assoc.field.getAnnotation(CascadeIgnore.class) == null) {

        List<? extends Model> childModels =
            Ebean.createQuery(assoc.clazz)
                .where()
                .eq(assoc.field.getName() + ".id", getId())
                .findList();
        for (Model child : childModels) {
          // If it is required, delete it, otherwise set it to null
          if (assoc.required) {
            child.delete();
          } else {
            try {
              assoc.field.set(child, null);
              Set<String> set = new HashSet<String>();
              set.add(assoc.field.getName());
              Ebean.update(child, set);
            } catch (IllegalAccessException e) {
              e
                  .printStackTrace(); // To change body of catch statement use File | Settings |
                                      // File Templates.
            }
          }
        }
      }
    }
  }
  public void runExampleUsingOrders() {

    LoadExampleData.load();

    PathProperties pathProperties =
        PathProperties.parse("(id,status,orderDate,customer(id,name),details(*,product(sku)))");

    Query<Order> query = Ebean.createQuery(Order.class);
    pathProperties.apply(query);

    List<Order> orders = query.where().gt("id", 1).findList();

    String rawJson = Ebean.json().toJson(orders);
    System.out.println(rawJson);
  }
 /**
  * Creates a query for the left (or parent) class
  *
  * @param params The parameters passed to the services
  * @return
  */
 protected Query<L> createLeftQuery(ServiceParams params) {
   return Ebean.createQuery(leftClass);
 }
 /**
  * Creates a query for the junction class
  *
  * @param params The parameters passed to the services
  * @return
  */
 protected Query<J> createJunctionQuery(ServiceParams params) {
   return Ebean.createQuery(junctionClass).fetch(rightFieldName);
 }