PeterB
PeterB

Reputation: 71

import-jdl fails when pasring entities

JHipster 7.7.0

I am trying to import the following JDL file:

entity UploadedResource {
    fileName String required,
    owner String required,
    uploadedBy String required,
    uploadTime Instant required,
    description String,
    fileSize Long,
    content Blob
}

entity SharedResource {
    resource UploadedResource required,
    url String required,
    public Boolean
}

entity ResourceDownload {
    resource UploadedResource required,
    downloadTime Instant required,
    user String
}

enum Language {
    ENGLISH, GERMAN, SPANISH, HUNGARIAN, ROMANIAN
}

relationship OneToOne {
    SharedResource{resource} to UploadedResource
}

relationship ManyToOne {
    ResourceDownload{resource} to UploadedResource
}

paginate UploadedResource with pagination

dto * with mapstruct

service all with serviceImpl

The import fails with the following error:

unknown field type

JDL Studio renders the relations correctly. Also, if I use the built in entity User, it complains about it too. If I only leave the UploadedResource entity and remove the others and the relationships, it works fine, the entity is created and I can use it in the application.

What could be the reason of the error message? No other entities are loaded into the application.

Upvotes: 0

Views: 293

Answers (1)

vicpermir
vicpermir

Reputation: 3702

The generator complains because you are mixing up entity and relationship definitions. It's better if entity blocks contain only field or enumerated types, and relationship blocks contain entity relationships.

This should work:

entity UploadedResource {
    fileName String required,
    owner String required,
    uploadedBy String required,
    uploadTime Instant required,
    description String,
    fileSize Long,
    content Blob
}

entity SharedResource {
    url String required,
    isPublic Boolean
}

entity ResourceDownload {
    downloadTime Instant required,
    user String
}

enum Language {
    ENGLISH, GERMAN, SPANISH, HUNGARIAN, ROMANIAN
}

relationship OneToOne {
    SharedResource{resource required} to UploadedResource
}

relationship ManyToOne {
    ResourceDownload{resource required} to UploadedResource
}

paginate UploadedResource with pagination

dto * with mapstruct

service all with serviceImpl

Another small problem is that you used public as a field name in SharedResource but this is a reserved keyword in Java, I changed it to isPublic.

I also added the required flag to both of your relationship definitions since it seems that is what you were trying to do.

Upvotes: 1

Related Questions