Why my JDL fixture didnt work – case stude

It’s time to generate MVP application in one line! To generate it from input.jh file we can use command:

yo jhipster:import-jdl .jhipster\input.jh

And after project was generated I tried to run it using gradlew bootRun command. The first problem was an event:

C:\hip\eventsearch\src\main\java\com\pdb\eventsearch\domain\Event.java:73: error: variable event is already defined in class Event
private Series event;
 C:\hip\eventsearch\src\main\java\com\pdb\eventsearch\domain\Event.java:251: error: method getEvent() is already defined in class Event
public Series getEvent() {

We had created event in three places: for relations with City, Series and Topics entities. This caused our problem, that variable event was already defined 🙂 We need modify a little bit out JDL to make it work correctly. Let’s try with refactoring of relationships:

relationship OneToMany {
   City{city} to Event{eventInCity},
    Series{series} to Event{eventInSeries},
    Event{event} to Topic{topicInEvent}

We need to import jdl file, remove and create database, next rebuild the project.

Jee, it’s almost working! Data are being added in correct way, but still there is some problem with selectbox from relationship. Automatically JHipster displays only record ID. You can modify it in generated json file, searching for parameter:


We need to change otherEntityField to be rather like:

 "otherEntityField": "name"

and regenerate just two modified entities: Topics and Event. You can regenerate all entities or choosen one, depending on what you need. Looks cool! To do this please use commands from below.

yo jhipster:entity event
yo jhipster:entity topic

It looks like below and you can replace existing files and rebuild the project 🙂

C:\hip\eventsearch>yo jhipster:entity event

Found the .jhipster/Event.json configuration file, entity can be automatically generated!

The entity event is being updated.

? Do you want to update the entity? This will replace the existing files for this entity, all your custom code will be overwritten (Use arrow keys)
> Yes, re generate the entity
  Yes, add more fields and relationships
  Yes, remove fields and relationships
  No, exit




Application is working as simply as design 😉 You can run it with code from repo available here. In next episodes we will try to improve the implementation to look better.

Paweł Dobrzański

Start-up's fan, technological conferences member, social media enthusiast and low-cost trips traveler.

You may also like



Witaj na moim blogu! Znajdziesz tu proces budowania mojej aplikacji EventSearch za pomocą jhipstera. Podzielę się z Tobą niuansami dot. zakładania i prowadzenia firmy. Mam również nadzieję, że pomogę Ci zaoszczędzić trochę pieniędzy. Zapraszam!

Najpopularniejsze posty

Dzięki, że wpadłeś!

Paweł Dobrzański

Paweł Dobrzański

Start-up's fan, technological conferences member, social media enthusiast and low-cost trips traveler.