休眠大写

发布于 2024-09-08 17:29:32 字数 457 浏览 0 评论 0原文

当我尝试使用 hibernate xml 映射文件 ...hbm.xml 将数据库中的表与应用程序中的 bean 映射时,每次运行应用程序时都会得到以下结果:

信息:找不到表:物种 初始 SessionFactory 创建 failed.org.hibernate.HibernateException: 缺失表:物种

我意识到问题是 hibernate 无法识别我的表,因为我在数据库中以小写形式保存了它。

我意识到这一点是因为当我在创建和删除模式下更改属性 hibernate.hbm2ddl.auto (放置在 hibernate.cfg.xml 中,我将其置于验证模式)时,它会起作用,因为它会创建一个全部大写的新表(包括列名称)并让旧的小写而不做任何更改。

我认为这与休眠配置有关,所以...

我如何更改休眠配置以理解我的数据库的小写配置?

When I try to map a table in my database with a bean in my application using hibernate xml mapping files ...hbm.xml I obtein the fallowing resulteverytime I run the app:

INFO: table not found: especies
Initial SessionFactory creation
failed.org.hibernate.HibernateException:
Missing table: especies

I've realize the problem is that hibernate doesn´t recognize my table because I have it in lowercase in the db.

I realize about this because when I change the property hibernate.hbm2ddl.auto (placed in the hibernate.cfg.xml, I have it in validate mode) in create and drop mode it works because it create a new table all in uppercase(included column names) and let the old one in lowercase with no change.

I assume this is something about the hibernate conguration, so...

How can I change the hibernate configuration to understand my lowercase configuration of the db?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吻泪 2024-09-15 17:29:32

默认情况下,Hibernate 使用 DefaultNamingStrategy,它使用大小写混合的数据库对象名称。这通常效果不佳。它提供了一个名为 ImprovedNamingStrategy< /code>,它使用下划线而不是混合大小写,这通常更适合数据库。

如何配置取决于您的设置,但您没有说明是否使用注释或 XML 配置。

By default, Hibernate uses the DefaultNamingStrategy, which uses mixed-case database object names. This often doesn't work well. It provides an alternative called ImprovedNamingStrategy, which uses underscores rather than mixed case, which is often a better fit for the database.

How you configure this depends on your setup, but you haven't said if you're using annotations or XML config.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文