hibernate ImprovedNamingStrategy覆盖实体中的表名 [英] hibernate ImprovedNamingStrategy overrides Table name in entity

查看:451
本文介绍了hibernate ImprovedNamingStrategy覆盖实体中的表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用org.hibernate.cfg.ImprovedNamingStrategy,但是对于一个表,我明确指定了表名

  @ Table(name =EventLog,schema =eventlogs)

但hibernate似乎在寻找事件日志。不应该显式命名覆盖ImprovedNamingStrategy提供的命名

解决方案

这是org.hibernate.cfg.ImprovedNamingStrategy的行为,将混合大小写名称转换为嵌入的下划线名称。 http://docs.jboss.org/hibernate /core/3.5/api/org/hibernate/cfg/ImprovedNamingStrategy.html 。因此,如果您明确使用名称EventLog,它将转换为event_log。

如果您只想使用 @Table 中明确指定的名称,则应该使用org.hibernate .cfg.DefaultNamingStrategy。默认情况下,在实例化org.hibernate.cfg.Configuration对象时使用它。


I am using org.hibernate.cfg.ImprovedNamingStrategy, But for a table I have specified the table name explicitly

@Table(name="EventLog",schema = "eventlogs")

But hibernate seems to be looking for event_log. Shouldn't explicit naming override the one provided by ImprovedNamingStrategy

解决方案

It is the behavior of the org.hibernate.cfg.ImprovedNamingStrategy , which will convert the mixed case names to the embedded underscores name . http://docs.jboss.org/hibernate/core/3.5/api/org/hibernate/cfg/ImprovedNamingStrategy.html . So if you explicitly use the name "EventLog" , it will convert to the "event_log" .

If you simply want to use the name explicitly specified in the @Table , you should use the org.hibernate.cfg.DefaultNamingStrategy . By default it is used when you instantiate your org.hibernate.cfg.Configuration object

这篇关于hibernate ImprovedNamingStrategy覆盖实体中的表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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