Solve the problem that springdatajpa automatically converts hump to underscore when parsing Cloumn of entity class

When writing spring boot integrated jpa to write entity classes, the default naming strategy is to name fields separated by underscores. The following is the specific exception information

 

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'appversion0_.app_version'in'field list' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.mysql.jdbc.Util.handleNewInstance(Util.java:425) at com.mysql.jdbc.Util.getInstance(Util.java:408) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3970) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3906) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524)

 

It has been verified that the default strategy used by springdatajpa is ImprovedNamingStrategy 
, so modify the naming strategy of hibernate under the configuration and add 
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming to the application.properties file. The PhysicalNamingStrategyStandardImpl 
problem can be solved satisfactorily

 

https://blog.csdn.net/u013030980/article/details/78135335

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325340558&siteId=291194637
Recommended