The import-jdl is currently broken with relationships to User
Here the stacktrace:
➜ jhipster import-jdl bug-tracker.jh
INFO! Using JHipster version installed globally
INFO! Executing import-jdl bug-tracker.jh
INFO! Options: from-cli: true, inline:
INFO! Found .yo-rc.json on path. This is an existing app
INFO! The JDL is being parsed.
Error: Can't add invalid relationship. Error: In the Many-to-One relationship from Ticket to User, only unidirectionality is supported for a Many-to-One relationship, you should create a bidirectional One-to-Many relationship instead.
Error while parsing applications and entities from the JDL Error: Can't add invalid relationship. Error: In the Many-to-One relationship from Ticket to User, only unidirectionality is supported for a Many-to-One relationship, you should create a bidirectional One-to-Many relationship instead.
Error: Can't add invalid relationship. Error: In the Many-to-One relationship from Ticket to User, only unidirectionality is supported for a Many-to-One relationship, you should create a bidirectional One-to-Many relationship instead.
Generate a default JHipster project, and use this JDL:
https://github.com/jhipster/jdl-samples/blob/master/bug-tracker.jh
entity Project {
name String
}
entity Label {
label String required minlength(3)
}
entity Ticket {
title String required,
description String,
dueDate LocalDate,
done Boolean
}
relationship ManyToMany {
Ticket{label(label)} to Label{ticket}
}
relationship ManyToOne {
Ticket{project(name)} to Project,
Ticket{assignedTo(login)} to User{ticket}
}
paginate Ticket with pagination
It's probably related to JHipster Core 6.
6.5.0 and master
Ticket{assignedTo(login)} to User{ticket}
This really is confusing. It seems like User will have a field named ticket of type Ticket.
First issue is the one you mentioned @pmverma, can you guess the other one?
The log message is a bit confusing too. But I think it may be a generic one.
Yup the error message sucks, I'm changing it now.
That isn't the worst though. It will inject a ticket field in the User entity, right? But can we? I don't see a skipped user management mentioned anywhere...
The first issue hides this one here.
Thanks @pmverma for your remark on the error message, I'm gonna change it right now.
@pascalgrimaud the sample is just wrong. It shouldn't have worked before.
You should either:
skipUserManagement option (in this case)Correct me if I'm wrong please.
Original sample (simplified):
entity Ticket
relationship ManyToOne {
Ticket{assignedTo(login)} to User{ticket}
}
The error message says:
Error: Can't add invalid relationship. Error: In the Many-to-One relationship from Ticket to User, only unidirectionality is supported for a Many-to-One relationship, you should create a bidirectional One-to-Many relationship instead.
Possible solution (MtO, unidirectional):
entity Ticket
relationship ManyToOne {
Ticket{assignedTo(login)} to User
}
Works because:
Other solution (OtM, bidirectional):
entity Ticket
relationship OneToMany {
User{ticket} to Ticket{assignedTo(login)}
}
Note that it won't work because we inject a field in the User here, so:
skipUserManagement flag is set in the CLI@MathieuAA : just try this JDL, using ManyToOne:
entity Project {
name String
}
entity Label {
label String required minlength(3)
}
entity Ticket {
title String required,
description String,
dueDate LocalDate,
done Boolean
}
relationship ManyToMany {
Ticket{label(label)} to Label{ticket}
}
relationship ManyToOne {
Ticket{project(name)} to Project,
Ticket{assignedTo(login)} to User
}
paginate Ticket with pagination
I can generate correctly the entities.
Once, I started the application, I can't add a User to a Ticket, either a Project.
So the create / update are broken here.
You can use my project:
Latest updates after (too?) many tests:
thanks @MathieuAA for the analyze !
I think the title should be renamed to 'Invalid relationships are noticed by the JDL' (yep, I'm trolling).
I've updated the PR, it should be good to go
Closed by jhipster-core v6.0.4.
@MathieuAA : don't forget to claim the bounty here, you deserved it !
Thanks, bounty claim: https://opencollective.com/generator-jhipster/expenses/11777
was too lazy to create two separate claims...