hibernate:创建名称为小写的表 [英] hibernate: create table with names in lowercase

查看:131
本文介绍了hibernate:创建名称为小写的表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如,如果我的类被称为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:创建名称为小写的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆