我正在用 jHipster 做一个实验。
我创建了两个由 DTO(mapstruct)支持的实体 A 和 B。它们之间存在多对多的关系。它们都与用户具有多对一的关系。
直到创建最后一个关系,一切正常。创建最后一个多对一关系后,出现以下错误:
[INFO] --- maven-processor-plugin:2.2.4:process (process) @ m2m ---
[ERROR] diagnostic: /Users/andy/jhipster-m2m/src/main/java/com/m2m/web/rest/mapper/AMapper.java:18: error: Ambiguous mapping methods found for mapping property "java.lang.Long userId" to com.m2m.domain.User: com.m2m.domain.User userFromId(java.lang.Long id), com.m2m.domain.User com.m2m.web.rest.mapper.BMapper.userFromId(java.lang.Long id).
A aDTOToA(ADTO aDTO);
^
[ERROR] error on execute: error during compilation
定义非常简单: 对于 A:
{
"relationships": [
{
"relationshipId": 1,
"relationshipName": "b",
"otherEntityName": "b",
"relationshipType": "many-to-many",
"otherEntityField": "id",
"ownerSide": true
},
{
"relationshipId": 2,
"relationshipName": "user",
"otherEntityName": "user",
"relationshipType": "many-to-one",
"otherEntityField": "id"
}
],
"fields": [
{
"fieldId": 1,
"fieldName": "nameA",
"fieldType": "String"
}
],
"changelogDate": "20150909165353",
"dto": "mapstruct",
"pagination": "no"
}
对于 B:
{
"relationships": [
{
"relationshipId": 1,
"relationshipName": "a",
"otherEntityName": "a",
"relationshipType": "many-to-many",
"ownerSide": false,
"otherEntityRelationshipName": "b"
},
{
"relationshipId": 2,
"relationshipName": "user",
"otherEntityName": "user",
"relationshipType": "many-to-one",
"otherEntityField": "id"
}
],
"fields": [
{
"fieldId": 1,
"fieldName": "nameB",
"fieldType": "String"
}
],
"changelogDate": "20150909165433",
"dto": "mapstruct",
"pagination": "no"
}
我真的坚持这一点。很感谢任何形式的帮助!!
编辑:提供演示问题的 github 存储库https://github.com/andyverbunt/jhipster-m2m.git