Reputation: 181
I have an existing database that I am using with jhipster, The issue is that I have a field named country_iso2 but it seems jhipster adds another underscore just before the number i.e country_iso_2. I have specified the column name in my dto class. Below is my entity
entity Documenttypes(document_types) {
name String required maxlength(255),
status Integer required,
countryIso2 String maxlength(2),
createdAt Instant required,
createdBy Integer
}
And this is my DTO class
public class DocumenttypesDTO implements Serializable {
private Long id;
@NotNull
@Size(max = 255)
private String name;
@NotNull
private Integer status;
@Size(max = 2)
@Column(name="country_iso2")
private String countryIso2;
@NotNull
private Instant createdAt;
private Integer createdBy;
//Getters and setters
}
When the code is Run I get the below error
Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet Caused by: java.sql.SQLSyntaxErrorException: Unknown column 'documentty0_.country_iso_2' in 'field list'
How then can I specify the field in the database inside the jhipster project so as not to have this issue.
Upvotes: 2
Views: 349
Reputation: 181
Was changing the column in the wrong class. The correct class is located in the com...domain Package. In that class you can be able to specify the column name.
I was able to change from the code below:
@Size(max = 2)
@Column(name = "country_iso_2", length = 2)
private String countryIso2;
To the below code:
@Size(max = 2)
@Column(name = "country_iso2", length = 2)
private String countryIso2;
Upvotes: 1