jhipster / jhipster-core

JHipster Domain Language, used by JHipster UML and JDL-Studio to generate entities
Apache License 2.0
346 stars 116 forks source link

ManyToOne with 'required' problem #337

Closed walshe closed 5 years ago

walshe commented 5 years ago
Overview of the issue

Create page of Book entity has issues - mainly the required Author field (dropdown) does not work

Motivation for or Use Case

need 'required' on a many to one relationship

Reproduce the error

import following app and then try to create a book, theres a greyed out id field and the drops down to select an author is non functional also

application { 

  config { 

    baseName bookstore

    packageName com.bookstore

    applicationType monolith 

    databaseType sql 

    devDatabaseType h2Disk 

    prodDatabaseType mysql 

    cacheProvider ehcache 

    enableHibernateCache true 

    authenticationType jwt 

    clientFramework angularX 

    useSass false 

    clientPackageManager npm 

    enableTranslation false 

    languages [ en, zh-cn, es ] 

    messageBroker false 

    searchEngine elasticsearch 

    serverPort 8080 

    websocket false 

    testFrameworks [protractor, cucumber, gatling] 

    buildTool maven 

  } 

  entities * 

} 

entity Book {
  name String required
  bookDesc String
}

entity Author {
  name String required
  authorDesc String required
}

relationship ManyToOne {
  Book{author(name) required } to Author
}

dto * with mapstruct   

paginate Author with pagination

paginate Book with pager

service * with serviceClass 

search * with elasticsearch 

filter * 
Related issues
Suggest a Fix

must be something to do with 'required' on many to one

JHipster Version(s)

JHipster v6.0.1

JHipster configuration
{
  "generator-jhipster": {
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "jhiPrefix": "jhi",
    "languages": [
      "en",
      "zh-cn",
      "es"
    ],
    "messageBroker": false,
    "nativeLanguage": "en",
    "packageName": "com.simple",
    "packageFolder": "com/simple",
    "prodDatabaseType": "mysql",
    "searchEngine": "elasticsearch",
    "serviceDiscoveryType": false,
    "skipClient": false,
    "skipServer": false,
    "testFrameworks": [
      "protractor",
      "cucumber",
      "gatling"
    ],
    "websocket": false,
    "baseName": "simple",
    "applicationType": "monolith",
    "cacheProvider": "ehcache",
    "authenticationType": "jwt",
    "clientFramework": "angularX",
    "useSass": true,
    "clientPackageManager": "npm",
    "serverPort": "8080",
    "buildTool": "maven",
    "jhipsterVersion": "6.0.1",
    "skipUserManagement": false,
    "jwtSecretKey": "HIDDEN",
    "clientTheme": "none",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": []
  },
  "entities": [
    "Book",
    "Author"
  ]
}
Entity configuration(s) entityName.json files generated in the .jhipster directory
{
    "name": "Book",
    "fields": [
        {
            "fieldName": "name",
            "fieldType": "String",
            "fieldValidateRules": [
                "required"
            ]
        },
        {
            "fieldName": "bookDesc",
            "fieldType": "String"
        }
    ],
    "relationships": [
        {
            "relationshipType": "many-to-one",
            "otherEntityName": "author",
            "otherEntityRelationshipName": "book",
            "relationshipValidateRules": "required",
            "relationshipName": "author",
            "otherEntityField": "name"
        }
    ],
    "changelogDate": "20190609191129",
    "entityTableName": "book",
    "dto": "mapstruct",
    "pagination": "pager",
    "service": "serviceClass",
    "jpaMetamodelFiltering": true,
    "fluentMethods": true,
    "clientRootFolder": "",
    "applications": [
        "simple"
    ],
    "searchEngine": "elasticsearch"
}
Browsers and Operating System

Chrome Version 74.0.3729.169 MacOs 10.11.6

MathieuAA commented 5 years ago

Interesting, the JSON looks okay. I'm gonna do some tests

pascalgrimaud commented 5 years ago

I think it's already fixed in master branch of generator-jhipster

See the ticket https://github.com/jhipster/generator-jhipster/issues/9780 with this https://github.com/jhipster/generator-jhipster/issues/9780#issuecomment-496457667

And this PR https://github.com/jhipster/generator-jhipster/pull/9806

walshe commented 5 years ago

oh cool, when will it be released ?

pascalgrimaud commented 5 years ago

@walshe : as always, with JHipster, we can't give you a release date, as all the work is done during our free and personal time... But we'll try to do a release very soon, before the JHipster Conf, at the end of the month

walshe commented 5 years ago

fair enough, are there any instructions on how to clone from master and run from that?

MathieuAA commented 5 years ago

There has been a release, so @walshe can you update your node modules and test this one out? thanks :)

walshe commented 5 years ago

it works great now thanks :)

am having issues with the jhipster aws generator now though..

MathieuAA commented 5 years ago

I suggest you look at SO posts and/or ask in the Gitter. If you believe you experience an actual issue, post it in the generator's issue tracker :)