Closed pvliss closed 5 years ago
Just tried out master generator + master jhipster-core, and I'm seeing this on ManyToOne's as well.
From the docs @ https://www.jhipster.tech/managing-relationships/#2, this is valid syntax:
entity Owner
entity Car
relationship ManyToOne {
Car{owner} to Owner
}
Take this JDL:
application {
config {
baseName gateway,
applicationType gateway,
authenticationType oauth2,
packageName com.example.gateway,
prodDatabaseType mariadb,
clientFramework react,
languages [en],
buildTool gradle
}
entities *
}
application {
config {
baseName person,
applicationType microservice,
authenticationType oauth2,
packageName com.example.person,
prodDatabaseType mariadb,
buildTool gradle
}
entities Person, PersonAttribute, Identifier, IdentifierType
}
entity Person {
uid String,
createdAt Instant,
lastUpdate Instant
}
entity PersonAttribute {
key String required,
value String,
createdAt Instant,
lastUpdate Instant
}
entity Identifier {
data String required,
createdAt Instant,
lastUpdate Instant
}
entity IdentifierType {
value String required,
description String,
createdAt Instant,
lastUpdate Instant
}
relationship OneToMany {
Person{personAttribute} to PersonAttribute{person}
}
relationship ManyToOne {
Identifier{identifierType} to IdentifierType
}
paginate * with pagination
dto * with mapstruct
service * with serviceClass
microservice Person, PersonAttribute, Identifier, IdentifierType with person
Produces:
WARNING! otherEntityRelationshipName is missing in .jhipster/Identifier.json for relationship {
"relationshipType": "many-to-one",
"relationshipName": "identifierType",
"otherEntityName": "identifierType",
"otherEntityField": "id",
"otherEntityRelationshipNameUndefined": true,
"otherEntityRelationshipName": "identifier"
}, using identifier as fallback
Thanks @jsm174 for reporting once more. To be honest I only checked the OneToMany
case. I will check again later tonight when I get some free time
@jsm174 Sorry for the delay but was quite busy. I submitted another PR that hopefully fixes all other cases as well, i.e. it always tries to set the otherEntityRelationshipName
to either the one provided in the jdl or automatically. This will make the generator to stop issuing warnings
Overview of the issue
It has been reported by @jsm174 at Gitter that JHipster now generates warnings for missing
otherEntityRelationshipName
while it is actually defined. Quoting here his message from Gitter:He is in fact right that JHipster should not complain and this is a byproduct of the changes I made to https://github.com/jhipster/generator-jhipster/issues/8991. The bug is actually in the JSON file generated by JDL import where the 'otherEntityRelationshipName' is missing.
Motivation for or Use Case
The JDL import should generate a valid JSON file with all defined attributes
I have spotted the bug in
lib/parser/entity_parser.js
and more specifically at methodsetDestinationAssociationsForClass
and will provide a PRReproduce the error
For example the
test/test_files/big_sample.jdl
theEmployee{job} to Job{employee}
defines theotherEntityRelationshipName
asemployee
but if you see the generated json file for Job theotherEntityRelationshipName
is missing.Related issues
Relates to https://github.com/jhipster/generator-jhipster/issues/8991
Suggest a Fix
Already found a fix and will submit a PR.
JHipster Version(s)
5.8.0