Recently, because rare words are displayed as
The main reason is that this field is of varchar type in the database, and what is displayed is?; Such as Yan; Now the varchar type is changed to nvarchar type; The data can be displayed normally
However, when the springboot program JPA executes the native stored procedure, it will report the following error
After verification, it is due to the dialect configuration problem of Hibernate database; Add database dialect configuration
The dialect needs to be rewritten
package com.winning.thread;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.type.StandardBasicTypes;
import java.sql.Types;
public class MyDialect extends SQLServerDialect {
public MyDialect() {
super();
registerHibernateType(Types.NCHAR, StandardBasicTypes.CHARACTER.getName());
registerHibernateType(Types.NCHAR, 1, StandardBasicTypes.CHARACTER.getName());
registerHibernateType(Types.NCHAR, 255, StandardBasicTypes.STRING.getName());
registerHibernateType(Types.NVARCHAR, StandardBasicTypes.STRING.getName());
registerHibernateType(Types.LONGNVARCHAR, StandardBasicTypes.TEXT.getName());
registerHibernateType(Types.NCLOB, StandardBasicTypes.CLOB.getName());
}
}
Can be displayed normally!
The following two articles are referred to solve:
https://stackoverflow.com/questions/27039300/jpa-sql-server-no-dialect-mapping-for-jdbc-type-9
https://stackoverflow.com/questions/47270883/spring-boot-wont-load-user-defined-dialect
Similar Posts:
- [Solved] Java:Hibernate Error executing DDL via JDBC Statement
- [Solved] mapper.xml Error: java.lang.AbstractMethodError: Method oracle/jdbc/driver/OracleResultSetImpl.getNString(Ljava/lang/String;)Ljava/lang/String; is abstract,
- Solve the error of springboot failed to load ApplicationContext
- [Solved] Oracle :value too large for column “SCHEMA”.”TABLE”.”COLUMN” (actual: 519, maximum: 500)
- Get the time value from the database and report an error: Java sql. Timestamp cannot be cast to java. lang.Long
- ERROR: syntax error at end of input & Database Error: invalid input syntax for type numeric: “Not reviewed”
- used in key specification without a key length
- Python bug problems and solutions sorted out in recent days
- Data truncation: Data too long for column ‘****’
- [Solved] org.hibernate.AnnotationException: No identifier specified for entity: com.example1.demo1.Entity….