I have created a jdl file using jdl-studio.
I tied to create entities from jdl file using jdl-import.
following is the snippet of my cmd terminal:
D:\spring-boot\examples\espressob>yo jhipster:import-jdl ./jhipster-jdl.jh
The jdl is being imported.
D:\spring-boot\examples\espressob>
the problem
It just prints that the jdl file is being imported, thats it.
I have checked if it generated code for entities from the jdl file, unfortunately it did not.
Env details
.yo-rc.json file content :
{
"generator-jhipster": {
"jhipsterVersion": "3.4.2",
"baseName": "espressob",
"packageName": "com.iwantunlimited.espressob",
"packageFolder": "com/iwantunlimited/espressob",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"clusteredHttpSession": "hazelcast",
"websocket": "spring-websocket",
"databaseType": "sql",
"devDatabaseType": "postgresql",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"buildTool": "maven",
"enableSocialSignIn": true,
"jwtSecretKey": "790501d7e04040394e33964a4ee715408ec0408f",
"useSass": true,
"applicationType": "monolith",
"testFrameworks": [
"gatling",
"cucumber",
"protractor"
],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"fr",
"hi"
]
}
}
jhipster-jdl.jh file content:
entity InsuranceCategory {
name String required,
description String,
isActive Boolean,
createdDate ZonedDateTime,
modifiedDate ZonedDateTime,
}
relationship ManyToOne {
InsuranceCategory{createdBy} to User
}
relationship ManyToOne {
InsuranceCategory{modifiedBy} to User
}
entity InsuranceProvider {
name String required,
isActive Boolean,
createdDate ZonedDateTime,
modifiedDate ZonedDateTime,
}
relationship ManyToOne {
InsuranceProvider{createdBy} to User
}
relationship ManyToOne {
InsuranceProvider{modifiedBy} to User
}
relationship ManyToMany {
InsuranceCategory{provider} to InsuranceProvider{category}
}
entity Policy {
name String required,
isActive Boolean,
createdDate ZonedDateTime,
modifiedDate ZonedDateTime,
}
relationship ManyToOne {
Policy{createdBy} to User
}
relationship ManyToOne {
Policy{modifiedBy} to User
}
relationship OneToMany {
InsuranceCategory{policy} to Policy
}
relationship OneToMany {
InsuranceProvider{policy} to Policy
}
dto all with mapstruct
Tried :
removing relationships with User entity -> not working
re arranging sequence of entries in jdl file (first all entities, then relationships) -> not working
I try your jdl-file with jhipster 3.6.1 version and it works with the following warning:
$ yo jhipster:import-jdl ./jhipster-jdl.jh
The jdl is being parsed.
**Warning: An Entity name 'User' was used: 'User' is an entity created by default by JHipster. All relationships toward it will be kept but any attributes and relationships from it will be disregarded.**
Writing entity JSON files.
Generating entities...
Also would recommend removing the commas at the end of the last field in the entities definitions:
entity InsuranceProvider {
name String required,
isActive Boolean,
createdDate ZonedDateTime,
modifiedDate ZonedDateTime
}
Instead of:
entity InsuranceProvider {
name String required,
isActive Boolean,
createdDate ZonedDateTime,
modifiedDate ZonedDateTime ,
}
Related
I am new to using Jhipster, I generated a gateway application in which I am trying to create entities that allow filtering as indicated in https://www.jhipster.tech/entities-filtering/
My JDL application looks like this:
application {
config {
baseName Appcommun,
applicationType gateway,
packageName co.appcommunity.gateway,
serviceDiscoveryType eureka,
authenticationType jwt,
databaseType sql,
devDatabaseType h2Disk,
prodDatabaseType mysql,
cacheProvider hazelcast,
buildTool maven,
clientFramework angularX,
enableTranslation true,
nativeLanguage es,
languages [es, en],
testFrameworks [protractor]
}
entities *
}
entity Community {
name String required unique,
description String,
code String required unique,
location String,
address String required,
logo String
}
dto * with mapstruct
filter Community
service * with serviceClass
When I run the Jhipster jdl jdlfile.jdl
You can see the following messages:
info: The filter option is set for Community, the 'serviceClass' value for the 'service' is gonna be set for this entity if no other value has been set.
WARNING! Not compatible with jpaMetamodelFiltering, disabling
Generated Entity JSON looks like:
{
"name": "Community",
"fields": [
{
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": ["required", "unique"]
},
{
"fieldName": "description",
"fieldType": "String"
}
],
"relationships": [],
"entityTableName": "community",
"dto": "mapstruct",
"pagination": "no",
"service": "serviceClass",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"readOnly": false,
"embedded": false,
"applications": ["easycommuniy"],
"databaseType": "sql",
"changelogDate": "20210603013758"
}
No filter service was generated.
Can any body say me what I'm doing wrong?
Can someone give me some hints? What am I doing wrong?
I tried to put jpaMetamodelFiltering": true, and regenerate the entity with the same result.
Thanks.
I am using jhipster version v6.5.0
When I am creating microservice gateway it asks for a database with the following error.
ERROR! Error: The entity cannot be generated as the application does not have a database configured!
Actually First I created a gateway with database and entities will work after my microservices are not running. That means it works as monolithic and I could see all JPA servicers in the gateway. Swagger API showing fine. But menu from Entities not using microservices.
.yo-rc.json
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.xxx.gate",
"nativeLanguage": "en"
},
"jhipsterVersion": "6.5.0",
"applicationType": "gateway",
"baseName": "myGate2",
"packageName": "com.xxx.gate",
"packageFolder": "com/xxx/gate",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "hazelcast",
"enableHibernateCache": false,
"websocket": "spring-websocket",
"databaseType": "no",
"devDatabaseType": "no",
"prodDatabaseType": "no",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "maven",
"enableSwaggerCodegen": false,
"jwtSecretKey": "XXXXXXXX",
"embeddableLaunchScript": false,
"useSass": true,
"clientPackageManager": "npm",
"clientFramework": "angularX",
"clientTheme": "lumen",
"clientThemeVariant": "dark",
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [],
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en"
],
"blueprints": []
}
Please help
JHipster gateway does not persist entities, it's the responsibility of the microservices. This is why you are not able to generate entities in your gateway, the gateway will only import your microservices entities to generate frontend for them.
Rather than converting your monolith into a gateway, you should import your existing entities into a new service.
I tried several possibilities. After changing my angular service class below it starts working as expected(calling microservice rather going directly to gateway).
Generated
public resourceUrl = SERVER_API_URL + 'api/countries';
Changed to
public resourceUrl = SERVER_API_URL + 'services/myservice/api/countries';
I am not sure that is the correct way that Jhipster expected. I have noticed that in gateway SORS filter too.
If you have any git project build with Angular Entities it would be great to understand better.
Thank you for your attention and help.
I'm using jhipster-generator 4.14.5 and im trying to generate an Entity with a field Persons. But Persons is a List of String List<String> Persons.
How can i achieve it in JHipster. I tried to generate a simple field as String, then i changed the POJO like this :
#ElementCollection
#Column(name="persons")
List<String> persons;
The domain.json containing the whole table remain not touched.
I tried to run the application, after running liquibase:diff, without success. How can i fix it?
Use the generator entity to create a relationship :
Create an entity Person (maybe with only the "name", but more fields will soon be needed. Like "active", some dates ...)
.jhipster/[YourEntity].json should contain :
"fields": [
{
"fieldName": "xxx",
"fieldType": "Integer"
}
],
"relationships": [
{
"relationshipName": "person",
"otherEntityName": "person",
"relationshipType": "one-to-many",
"relationshipValidateRules": [
"required"
],
"otherEntityField": "name"
}
],
don't forget to commit before using the generator. Maybe you will need multiple executions to get it right.
[JHipster Generator 4.14.4]
i generate an "article" with some relationships with JDL Studio. Relationships in my article.json look like this :
"relationships": [
{
"relationshipType": "one-to-one",
"relationshipName": "adress",
"otherEntityName": "adressDomain",
"otherEntityField": "id",
"ownerSide": true,
"otherEntityRelationshipName": "article"
},
How can i add the required rules to my relationship?
i tried "relationshipValidateRules": "required" but it doesnt works.
My Answer is not to change in the JSON File but to regenerate the *.jh file on JDL-Studio.
Here is how to add the required:
relationship OneToOne {
Article{adress required} to AdressDomain
}
Im writing a Jhipster generator module and I need to scaffold a new entity. Just like running jhipster:entity but inside the generator javascript
How should I do this? I see in the base generator methods "addEntityToCache(...)", "addEntityToMenu(...)". But I don't see: "addEntity(definition)" where definition is the configuration json that it's stored in .jhipster
It's this feature possible? can I extend the entity sub-generator to reuse the code?
Create entity.json file inside project/.jhipster
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "field_name_in_pojo_class",
"fieldType": "data_type_of_that_field"
}
],
"changelogDate": "20180523121144",
"dto": "no",
"service": "serviceClass",
"entityTableName": "entity_name_here",
"jpaMetamodelFiltering": false,
"pagination": "pagination",
"microserviceName": "project_name_here",
"searchEngine": false
}