Problem:
org.hibernate.HibernateException: Wrong column type Found: char, expected: varchar2(255)
This exception was raised for the mapping:
@Column(name = "CNTRY_NM")
public String getCountry() {
return country;
}
Analysis: This means to say that Hibernate has found char as the dataType of the column in the DATABASE and in your mapping you specified the data type as String.
- By default, the Hibernate converts java.lang.String to varchar2(255).
In other words, the data type of ‘CNTRY_NM’ column was defined as CHAR(50 Byte) in the database. Where as the data type of the corresponding attribute in the Entity class is java.lang.String. As there is a mismatch in the columns, the exception is thrown. When you specify schema validation by Hibernate (hibernate.hbm2ddl.auto = validate) this exception is thrown.
Solution:
@Column(name = "CNTRY_NM", columnDefinition = "char")
public String getCountry() {
return country;
}
No comments:
Post a Comment