How to have a data type be the name of a field in JDL file (jHipster)

62 Views Asked by At

I have an entity in a JDL file.

entity Person {
  Name String,
  Duration Integer
}

The word 'Duration' is a data type in the Jhipster Domain Language. https://www.jhipster.tech/jdl/entities-fields

However, I need my entity to have this field name.

How can I have a field name 'Duration' be a valid field name? I have tried escaping it using double quotes, slashes, etc. but it's not working.

It underscores it red and says 'no viable alternative at input 'Duration''

1

There are 1 best solutions below

0
crowne On

The first problem is that the field names should be lowercase.
Try this:

entity Person {
  name String,
  duration Integer
}

I think the error which you are seeing is just visual feedback from the editor.
The application should still generate successfully, however it is preferable to stick to the standard naming conventions :

  • Class names begin with Uppercase
  • field names begin with lowercase
  • Enum names begin with Uppercase
  • ENUM_VALUES all UPPERCASE