code: public void setParent(Model parent) {
          if (parent == null || parent.getId() == null) {
              throw new IllegalArgumentException("parent cannot ne null and parent ID cannot be null");
          }
          List<Association> associations = metaModelLocal.getAssociations();
          for (Association association : associations) {
              if (association instanceof BelongsToAssociation && association.getTargetClass().equals(parent.metaModelLocal.getModelClass())) {
                  set(((BelongsToAssociation)association).getFkName(), parent.getId());
                  return;
              }
              if(association instanceof BelongsToPolymorphicAssociation && association.getTargetClass().equals(parent.metaModelLocal.getModelClass())){
                  set("parent_id", parent.getId());
                  set("parent_type", ((BelongsToPolymorphicAssociation)association).getTypeLabel());
                  return;
              }
          }
          StringBuilder sb = new StringBuilder();
          sb.append("Class: ").append(parent.getClass()).append(" is not associated with ").append(this.getClass())
                  .append(", list of existing associations:\n");
          join(sb, metaModelLocal.getAssociations(), "\n");
          throw new IllegalArgumentException(sb.toString());
      }
docs: Sets a parent on this instance. Basically this sets a correct value of a foreign key in a
  parent/child relationship. This only works for one to many and polymorphic associations.
  The act of setting a parent does not result in saving to a database.
  
  @param parent potential parent of this instance. Its ID value must not be null.