javaspring-bootjhipsterjdl

How to use List with JDL entities in Jhipster


I'm new to use Jhipster. I want to create a JDL entity using my existing model classes. Here is my model class.

@Data
public class ResponseJson implements Serializable {
    private List<String> names;
}

Normal JDL entity can be created like,

entity ResponseJson{
  names String
}

But I need to know how to use List in JDL entities.


Solution

  • You cannot use List directly

    Instead you can create a one-to-many relationship in order to make ResponseJson have multiple String by wrapping this String in another Object

    Your JDL should be:

    entity ResponseJson {
        ...
    }
    
    entity ObjectContainingString {
        name String
    }
    
    relationship OneToMany {
        ResponseJson{name} to ObjectContainingString{json}
    }