code: public String getNotNullAnnotation() {
          if (!relation.isManyToOne() && !relation.isOneToOne()) {
              return "";
          }
  
          if (relation.isMandatory() && !relation.hasInverse()) {
              if (relation.getFromEntity().getName().equals(relation.getToEntity().getName())) {
                  // TODO ?: mandatory relation on self is complicated to handled
                  // in tests (model generator)... so we just ignore it.
                  return "";
              }
  
              if (relation.getFromAttribute().isInPk()) {
                  // TODO: not sure why, but integration tests fail if we don't skip this case.
                  return "";
              }
  
              ImportsContext.addImport("javax.validation.constraints.NotNull");
              return "@NotNull";
          } else {
              return "";
          }
      }
docs: Applies only to ManyToOne or OneToOne.
  When x to one has an inverse relation, we never mark it as @NotNull
  as it would break navigation (indeed, the mandatory value is set transparently once the entity is added to the collection)
  However, in test (XxxGenerator), we must take mandatory into account...