Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make an entity relationship required

Tags:

jhipster

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?

like image 235
snovelli Avatar asked Aug 13 '15 11:08

snovelli


People also ask

Does every entity need a relationship?

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?

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.

How do you represent the relationship between two entities?

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.

What is mandatory participation in an entity relationship?

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.


2 Answers

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.

like image 65
Bukodi László Avatar answered Oct 22 '22 06:10

Bukodi László


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

like image 1
Gaël Marziou Avatar answered Oct 22 '22 04:10

Gaël Marziou