gpt4 book ai didi

hibernate - 有没有办法告诉 JPA/Hibernate 将列名从 camcel 大小写转换为 _'s?

转载 作者:行者123 更新时间:2023-12-01 02:56:01 26 4
gpt4 key购买 nike

有没有一种通用的方法来告诉 JPA/Hibernate 转换表单的所有列名:

电子邮件地址

到表格:

电子邮件地址

?

我宁愿不必对数百列使用 @Column 注释。我希望有人想到这一点;)

最佳答案

Hibernate Reference Documenation - 3.6.实现命名策略

The interface org.hibernate.cfg.NamingStrategy allows you to specify a "naming standard" for database objects and schema elements.

You can provide rules for automatically generating database identifiers from Java identifiers or for processing "logical" column and table names given in the mapping file into "physical" table and column names. This feature helps reduce the verbosity of the mapping document, eliminating repetitive noise (TBL_ prefixes, for example). The default strategy used by Hibernate is quite minimal. You can specify a different strategy by calling Configuration.setNamingStrategy() before adding mappings: ...



另见: http://www.javalobby.org/java/forums/t19838.html

关于hibernate - 有没有办法告诉 JPA/Hibernate 将列名从 camcel 大小写转换为 _'s?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2963725/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com