Jhipster - relationship (join) with another field (not id)
<p>I'm relatively new to JHipster.</p>

<blockquote>
  <p>This application was generated using JHipster 3.12.1</p>
</blockquote>

<p>I have the following jdl file:</p>

<pre><code>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
</code></pre>

<p>The jdl documentation states:</p>

<blockquote>
  <p>By default, the joining is done by the id field… But if you want the joining to be done by another field, then you can do things like:</p>
  
  <p>entity A {
         name String required
     }
     entity B</p>
  
  <p>relationship OneToOne {
         A{b} to B{a(name)}
     }</p>
</blockquote>

<p>The generated class (ZipCodeGeoBrg) has these attributes:</p>

<pre><code>@ManyToOne
private ZipCode zipCode;

@ManyToOne
private Country country;

@ManyToOne
private State state;
</code></pre>

<p>My entity class is generated but all the joins are on the id columns, not the named columns (e.g. countryCd). I expected something like this:</p>

<pre><code>@ManyToOne
@JoinColumn( name = "COUNTRY_CD" )
private Country country;

@ManyToOne
@JoinColumn( name = "STATE_CD" )
private State state;

@ManyToOne
@JoinColumn( name = "ZIP_CD" )
private ZipCode zipCode;
</code></pre>

<p>I've tried the jdl like this too:</p>

<pre><code>relationship OneToMany {
    ZipCode to ZipCodeGeoBrg{zipCode(zipCd)},
    Country to ZipCodeGeoBrg{country(countryCd)},
    State to ZipCodeGeoBrg{state(stateCd)}
}
</code></pre>

<p>and got the same results.</p>

<p>This is an existing database. The DBA is willing to update the tables and add an ID column, but is not willing to redo all the relationships (e.g. zip_cd is the existing column that relates ZipCode &lt;--> ZipCodeGeoBrg, and that's not going to change). So I have to make these work with columns that are not the ID. I know I can just update the Entities by hand after I generate, but I have 20 more tables to do and would rather have the tool do it for me.</p>

<p>What am I missing?</p>