Jhipster关系的CRUd问题

时间:2019-05-27 19:44:03

标签: jhipster jdl

我正在导入以下jdl以生成一个简单的jhipster整体。

启动后我检查了h2 db,它看起来很完美,但是当我尝试使用ui创建新的InventryModel或Inventory实体时,下拉列表根本无法正常工作。

当我添加{required}(以强制执行非null fks)时,这似乎是它开始走下坡路的地方

  config {
    baseName hipcars
    packageName com.hipcars
    applicationType monolith
    databaseType sql
    devDatabaseType h2Disk
    prodDatabaseType mysql
    cacheProvider ehcache
    enableHibernateCache true
    authenticationType jwt
    clientFramework angularX
    useSass false
    clientPackageManager npm
    enableTranslation false
    languages [ en, zh-cn, es ]
    messageBroker kafka
    searchEngine elasticsearch
    serverPort 8080
    websocket false
    testFrameworks [protractor, cucumber, gatling]
    buildTool gradle
  }
  entities *
}

entity Make {
  name String required unique maxlength(20),
  desc String
}

entity InventoryModel {
  name String required unique maxlength(20),
  vehicleType VehicleType
  desc String
}

enum VehicleType {
  SEDAN,
  COUPE
}

entity Inventory {
    vin String required unique maxlength(17),
  comment   String maxlength(128)
}

relationship ManyToOne {
  InventoryModel{make(name) required} to Make,
  Inventory{inventoryModel(name) required} to InventoryModel
}

dto * with mapstruct

paginate * with pagination
service * with serviceClass
search * with elasticsearch
filter *

但是,如果我这样做:

application {
  config {
    baseName hipcars
    packageName com.hipcars
    applicationType monolith
    databaseType sql
    devDatabaseType h2Disk
    prodDatabaseType mysql
    cacheProvider ehcache
    enableHibernateCache true
    authenticationType jwt
    clientFramework angularX
    useSass false
    clientPackageManager npm
    enableTranslation false
    languages [ en, zh-cn, es ]
    messageBroker kafka
    searchEngine elasticsearch
    serverPort 8080
    websocket false
    testFrameworks [protractor, cucumber, gatling]
    buildTool gradle
  }
  entities *
}

entity Make {
  name String required unique maxlength(20),
  desc String
}

entity InventoryModel {
  name String required unique maxlength(20),
  vehicleType VehicleType
  desc String
}

enum VehicleType {
  SEDAN,
  COUPE
}

entity Inventory {
    vin String required unique maxlength(17),
  comment   String maxlength(128)
}

relationship ManyToOne {
  InventoryModel{make(name)} to Make{required},
  Inventory{inventoryModel(name)} to InventoryModel{required}
}

dto * with mapstruct

paginate * with pagination
service * with serviceClass
search * with elasticsearch
filter *

原始屏幕运行良好,但是对Inventory.inventoryModel或InventoryModel.make没有“不是空”约束,这正是我真正需要的

1 个答案:

答案 0 :(得分:0)

尝试一下:

relationship ManyToOne {
  InventoryModel{make(name) required} to Make,
  Inventory{inventoryModel(name) required} to InventoryModel
}

代替此:

relationship ManyToOne {
  InventoryModel{make(name)} to Make{required},
  Inventory{inventoryModel(name)} to InventoryModel{required}
}