项目使用spring boot构建。开发的过程中遇到Spring Data JPA @Column 注解无效。
出现could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
的错误,这是由于jpa默认才用的命名策略的问题。
直接上解决方案
在application.properties用spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
替换
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
参考http://stackoverflow.com/questions/25283198/spring-boot-jpa-column-name-annotation-ignored
亲测有效,在配置文件里面改一下配置就好了

本文介绍了解决Spring Boot项目中SpringDataJPA的@Column注解无效问题的方法。通过调整Hibernate命名策略配置,成功解决了因默认命名策略导致的数据库交互错误。
3475

被折叠的 条评论
为什么被折叠?



