'String' 类型不支持验证“[object Object]”

The validation '[object Object]' isn't supported for the type 'String'

当我尝试使用 jHipster 重新生成模型时,出现以下错误:

The validation '[object Object]' isn't supported for the type 'String'.

对我做错了什么有什么想法吗?

我使用的jHipster版本是3.6.1。

{

    /**
     * Hierarchy entity.
     * @author Shane Hayes.
     */
    entity HierarchyServiceCenter  {
        hrchyNode1IPId Integer required,
        hrchyNode1IPNm String maxlength(40),
        hrchyNode1Dsgntn String,
        hrchyNode2IPId Integer ,
        hrchyNode2IPNm String maxlength(40),
        hrchyNode2Dsgntn String,
        hrchyNode3IPId Integer ,
        hrchyNode3IPNm String maxlength(40),
        hrchyNode3Dsgntn String,
        hrchyLeafCode Integer required,
        hrchyLeafIPNm String maxlength(40) required,
        hrchyLeafDsgntn String ,
        hrchyLeafLctnGNm String,
        hrchySource String,
        hrchyTimeStampCreate ZonedDateTime required,
        hrchyTimeStampUpdate ZonedDateTime ,
    }
    /**
     * TimeDimention entity.
     * @author Shane Hayes.
     */
    entity TimeDimension {
        createDate ZonedDateTime required,
        updateDate ZonedDateTime
    }
    /**
     * MetricDimention entity.
     * @author Shane Hayes.
     */
    entity MetricDimension {
        metricDimKey String required max(10),
        metricName String max(35),
        asOfDate ZonedDateTime,
        metricFrequency String max(1),
        srcSystemID Integer,
        createTmStamp ZonedDateTime,
        updateTmStamp ZonedDateTime
    }
    /**
     * MetricTarget entity.
     * @author Shane Hayes.
     */
    entity MetricTarget {
        goalAmt BigDecimal required,
        autoComputed Integer,
        asOfDate ZonedDateTime required,
        goalEffDate ZonedDateTime required,
        endDate ZonedDateTime required,
        srcSystemID Integer,
        createDate ZonedDateTime,
        updateDate ZonedDateTime
    }
    relationship ManyToOne {
        MetricTarget{metricDimension} to MetricDimension,
        MetricTarget{hierarchyLeafCode} to HierarchyServiceCenter{hrchyLeafCode},
        MetricTarget{hierarchyNode1IPId} to HierarchyServiceCenter{hrchyNode1IPId},
        MetricTarget{hierarchyNode2IPId} to HierarchyServiceCenter{hrchyNode2IPId},
        MetricTarget{hierarchyNode3IPId} to HierarchyServiceCenter{hrchyNode3IPId},
        MetricTarget{hierarchyNode4IPId} to HierarchyServiceCenter{hrchyNode4IPId},
        MetricTarget{timeDimensionId} to TimeDimension
    }
    entity MetricActual {
        actualAmt BigDecimal required,
        autoComputed Integer,
        asOfDate ZonedDateTime required,
        goalEffDate ZonedDateTime required,
        endDate ZonedDateTime required,
        srcSystemID Integer,
        createDate ZonedDateTime,
        updateDate ZonedDateTime
    }
    relationship ManyToOne {
        MetricActual{metricDimension} to MetricDimension,
        MetricActual{hierarchyLeafCode} to HierarchyServiceCenter{hrchyLeafCode},
        MetricActual{hierarchyNode1IPId} to HierarchyServiceCenter{hrchyNode1IPId},
        MetricActual{hierarchyNode2IPId} to HierarchyServiceCenter{hrchyNode2IPId},
        MetricActual{hierarchyNode3IPId} to HierarchyServiceCenter{hrchyNode3IPId},
        MetricActual{hierarchyNode4IPId} to HierarchyServiceCenter{hrchyNode4IPId},
        MetricActual{timeDimensionId} to TimeDimension
    }

}

首先删除所有包含的花括号。他们不应该在那里。其次将整个内容粘贴到 JDL studio 并确保它通过语法检查。它会在顶部用红色告诉你哪一行有问题(如果有的话)。

  • 第一个错误是JDL开头和结尾的大括号。

  • 第二个错误是 max(35) 个元素。您应该改为 maxlength(35)

  • 第三个错误是MetricTarget和MetricDimension之间以及MetricActual和MetricDimension之间的关系。这些是单向关系(ManyToOne)所以你应该写例如MetricTarget{hierarchyLeafCode} to HierarchyServiceCenter 而不是 MetricTarget{hierarchyLeafCode} to HierarchyServiceCenter{hrchyLeafCode}.