generator-jhipster: MappedBy reference an unknown target entity property (bidirecional)
Example my json:
"relationships": [
{
"relationshipId": 1,
"relationshipName": "Email",
"relationshipNameCapitalized": "Email",
"relationshipFieldName": "email",
"otherEntityName": "email",
"relationshipType": "one-to-many",
"otherEntityNameCapitalized": "Email",
"ownerSide": false
},
{
"relationshipId": 2,
"relationshipName": "Telefone",
"relationshipNameCapitalized": "Telefone",
"relationshipFieldName": "telefone",
"otherEntityName": "telefone",
"relationshipType": "one-to-many",
"otherEntityNameCapitalized": "Telefone",
"ownerSide": false
},
{
"relationshipId": 3,
"relationshipName": "Morada",
"relationshipNameCapitalized": "Morada",
"relationshipFieldName": "morada",
"otherEntityName": "morada",
"relationshipType": "one-to-many",
"otherEntityNameCapitalized": "Morada",
"ownerSide": false
}
]
...
Java generate based json:
....
@OneToMany(mappedBy = "contacto")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Email> emails = new HashSet<>();
@OneToMany(mappedBy = "contacto")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Telefone> telefones = new HashSet<>();
@OneToMany(mappedBy = "contacto")
@JsonIgnore
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Morada> moradas = new HashSet<>();
....
Image of diagram:

On debug generate error: Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: pt.zzzzz.domain.Email.contacto in pt.zzzzz.domain.Contacto.emails
How to your resolve this problem?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (13 by maintainers)
From what I understand, when you generate a OneToMany relationship between a Driver and his Cars, JHipster expects that the ‘driver’ field exists in the Car. Removing
mappedBy = "driver"in the OneToMany annotation in the Driver model might fix it. This or fixing it on the other side by creating the property or relationship.