Hello I'm generating some Entity with the jhipster generator.
When I generate an entity relationship, I'd like to make the value in that field mandatory but unfortunately, the generator doesn't provide that option.
Is there anyway to inform the generator of this necessity? (editing the .jhipster/entity_name.json), for example?
So to answer your question by one route: It's perfectly acceptable to have an entity on a diagram that has no relationship to any other entity. Consider a settings table that is used by a simple application to store the settings for the program. It would not need any other entities to do its job.
What steps are required in the development of an ER diagram? Identify, analyze, and refine the business rules. Identify the main entities, using the results of Step 1. Define the relationships among the entities, using the results of Steps 1 and 2.
Unary relationship (recursive) A unary relationship, also called recursive, is one in which a relationship exists between occurrences of the same entity set. In this relationship, the primary and foreign keys are the same, but they represent two entities with different roles.
In a mandatory relationship, every instance of one entity must participate in a relationship with another entity. In an optional relationship, any instance of one entity might participate in a relationship with another entity, but this is not compulsory.
Since this commit JHipster supports the required validation on relationships too.
This is an example from a JDL file:
relationship ManyToOne { Certificate{ca(name) required} to CertificateAuthority }
('Certificate' and 'CertificateAuthority' are entities and 'ca' is the field name)
The relevant part from the .jhipster/Certificate.json:
"relationships": [
{
"relationshipType": "many-to-one",
"relationshipValidateRules": "required",
"relationshipName": "ca",
"otherEntityName": "certificateAuthority",
"otherEntityField": "name"
},
The generated Certificate.ca field:
@ManyToOne @NotNull private CertificateAuthority ca;
And the generated form has a 'This field is required.' warning at the Ca filed.
No, it would be a new feature. Feel free to create an issue in our github project and pull requests are always welcome :)
Just for others, here is the issue you opened
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With