解决springdatajpa 在解析实体类的Cloumn的时候驼峰自动转为下划线问题

阅读更多

编写spring Boot集成jpa编写实体类的时候,默认使用的命名策略是下划线分隔的字段命名,以下为具体异常信息

 

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)

 

经查证springdatajpa使用的默认策略是ImprovedNamingStrategy 
所以修改配置下下hibernate的命名策略就可以了在application.properties文件中加入 
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl 
问题就可以圆满解决了

 

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

你可能感兴趣的:(解决springdatajpa)