我对JHipster比较陌生。Jhipster - 与另一个字段(不是id)的关系(加入)
使用JHipster 3.12.1生成该应用
我有以下JDL文件:
entity Country {
countryCd String minlength(2) maxlength(2) required,
countryNm String maxlength(64) required
}
entity State{
stateCd String minlength(2) maxlength(2) required,
stateNm String maxlength(40) ,
stateTypeCd String maxlength(1) required
}
entity ZipCode{
zipCd String maxlength(20) required
}
entity ZipCodeGeoBrg{
countryCd String minlength(2) maxlength(2) required,
zipCd String maxlength(20) required,
cityNm String maxlength(100) required,
stateCd String minlength(2) maxlength(2) required,
countyNm String maxlength(100) ,
countyCd String maxlength(20) ,
communityNm String maxlength(100) ,
communityCd String maxlength(20) ,
latitudeNum BigDecimal ,
longitudeNum BigDecimal,
accuracyNum Integer
}
relationship OneToMany {
ZipCode{zipCodeGeoBrg} to ZipCodeGeoBrg{zipCode(zipCd)},
Country{zipCodeGeoBrg(countryCd)} to ZipCodeGeoBrg{country(countryCd)},
State{zipCodeGeoBrg(stateCd)} to ZipCodeGeoBrg{state(stateCd)}
}
dto * with mapstruct
service all with serviceImpl
search ZipCodeGeoBrg with elasticsearch
的JDL文档状态:
默认情况下,加入是由id字段完成的......但是如果你想让加入由另一个字段完成,那么你可以做些事情E:
实体A { 名称需要字符串 } 实体B
关系OneToOne { A {B}到B {A(名称)} }
生成的类( ZipCodeGeoBrg)具有以下属性:
@ManyToOne
private ZipCode zipCode;
@ManyToOne
private Country country;
@ManyToOne
private State state;
我的实体类已生成,但所有j oins位于id列上,而不是命名列(例如, countryCd)。我希望这样的事情:
@ManyToOne
@JoinColumn(name = "COUNTRY_CD")
private Country country;
@ManyToOne
@JoinColumn(name = "STATE_CD")
private State state;
@ManyToOne
@JoinColumn(name = "ZIP_CD")
private ZipCode zipCode;
我已经试过了JDL这样太:
relationship OneToMany {
ZipCode to ZipCodeGeoBrg{zipCode(zipCd)},
Country to ZipCodeGeoBrg{country(countryCd)},
State to ZipCodeGeoBrg{state(stateCd)}
}
,并得到了相同的结果。
这是一个现有的数据库。 DBA愿意更新表格并添加一个ID列,但不愿意重做所有关系(例如,zip_cd是与ZipCode < - > ZipCodeGeoBrg相关的现有列,并且这不会改变)。所以我必须使这些工作与不是ID的列一起工作。我知道我可以在生成后手动更新实体,但我还有20个表要做,并且宁愿让该工具为我做。
我错过了什么?