问题描述
例如,如果我的类被称为com.myapp.domain.Customer, hibernate会生成一个名为Customer的表。我想把它叫做客户。我知道我可以使用@Table注释来指定每个类的表名。
Isn'it它的工作?
你将得到被管理的实体的名称(即Customer),并且应该决定使用的表名( entityName.toLowerCase()
)。
有一件事我不知道是否在生成表(hbm2ddl)时考虑了NamingStrategies。
Hibernate: I want to have hibernate automatically generate my tables with names in lowercase.
For example, if my class is called com.myapp.domain.Customer, hibernate will generate a table named Customer. I want it to be called customer. I know I can use the @Table annotation to specify the table name per class. But I want it to happen "automagically".
Isn'it it the job for NamingStrategy?
You would get the name of the entity managed (i.e. Customer) and should decide the table name used (entityName.toLowerCase()
in your case).
One thing I am not sure is if the NamingStrategies are taken into account when generating tables (hbm2ddl).
这篇关于hibernate:创建名称为小写的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!