Search code examples
javaormrelationshipjhipstercode-generation

JHipster: Error: In the relationship between Image and ImageType, ImageType is not declared


JHipster: Error: In the relationship between Image and ImageType, ImageType is not declared.

entity Image {
}
enum ImageType {
   MAIN
}
relationship OneToOne {
    Image{type} to ImageType
}

How to implement unidirectional one to one?


Solution

  • I think instead of having unidirectional one-to-one relationship, you want ImageType to be a field of Image:

    enum ImageType {
        MAIN
    }
    entity Image {
        type ImageType
    }
    

    If for some reason you actually want one-to-one relationship, you need to use your enum in an entity:

    enum ImageType {
        MAIN
    }
    entity ImageTypeEntity {
        type ImageType
    }
    entity Image {
    }
    relationship OneToOne {
        Image{imageTypeEntity} to ImageTypeEntity
    }