美文网首页sporingboot
Springboot Mysql JPA @Column 设置字

Springboot Mysql JPA @Column 设置字

作者: SlowGO | 来源:发表于2018-08-27 18:06 被阅读27次

问题


Springboot JPA 连接 Mysql,有一个字段名为 blockHash,entity 中明确指定了字段名:

...
@Column(name="blockHash")
public String blockHash;
...

就是为了防止字段名被自动拆为 block_hash,但这样依然无效。

解决方法


在配置文件中指定名字策略:

spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

这样就可以正确对应 blockHash 字段了。

相关文章

网友评论

    本文标题:Springboot Mysql JPA @Column 设置字

    本文链接:https://www.haomeiwen.com/subject/cvptwftx.html