private void setType(CascadeType type) {
   if (type.equals(CascadeType.ALL)) {
     save = true;
     delete = true;
   }
   if (type.equals(CascadeType.REMOVE)) {
     delete = true;
   }
   if (type.equals(CascadeType.PERSIST)) {
     save = true;
   }
   if (type.equals(CascadeType.MERGE)) {
     save = true;
   }
   if (save || delete) {
     validate = true;
   }
 }
Beispiel #2
0
  public String getAnnotation() {
    StringBuilder annotation = new StringBuilder("@ManyToOne(");

    if (fetchType != null) {
      annotation.append("fetch = FetchType.").append(fetchType.toString()).append(", ");
      super.addPackage(fetchType.getClass().getPackage().toString());
    }

    if (cascadeType != null) {
      annotation.append("cascade = CascadeType.").append(cascadeType.toString()).append(", ");
      super.addPackage(cascadeType.getClass().getPackage().toString());
    }

    if (optional != null) annotation.append("orphanRemoval = ").append(optional).append("\"");

    annotation.append(")");

    String value = annotation.toString();
    value = value.replace(", )", ")");
    return value;
  }