Hibernate不会在不同的操作系统下加载某个表 [英] Hibernate won't load certain table under different OS

查看:154
本文介绍了Hibernate不会在不同的操作系统下加载某个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Hibernate和mySQL。

我主要在Windows上开发java应用程序。所有的表格都是用小写字母创建的。



当我将它部署在linux服务器上时,我注意到表格现在处于正确的位置(java命名约定)。这很好,但所有,但由于某种原因,我oneToMany列表中的一个没有加载。



我没有使用任何其他查询,除了 from+ class.getName()



我试着改变 * lower_case_table_names = 2 * my.conf ,因此它在Windows中匹配,但是没有帮助。



其他想法? / p>



实际上,这很愚蠢。这是我在应用程序中导致问题的逻辑,我正在寻找一些部分提取。

解决方案

错误的选项,从手册引用:

http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html


lower_case_table_names =

0

表和数据库名称使用CREATE TABLE或CREATE DATABASE语句中指定的lettercase存储在磁盘上。名称比较区分大小写。如果您在具有不区分大小写的文件名(例如Windows或Mac OS X)的系统上运行MySQL,则不应将此变量设置为0。如果在不区分大小写的文件系统上使用--lower-case-table-names = 0强制将此变量设置为0,并使用不同的lettercase访问MyISAM表名,则可能导致索引损坏。



<1>

表名在磁盘上以小写形式存储,名称比较不区分大小写。 MySQL在存储和查找时将所有表名称转换为小写字母。此行为也适用于数据库名称和表别名。

2

表和数据库名称使用CREATE TABLE中指定的lettercase存储在磁盘上或CREATE DATABASE语句,但MySQL在查找时将它们转换为小写字母。名称比较不区分大小写。 这仅适用于不区分大小写的文件系统! InnoDB表名称以小写形式存储,与lower_case_table_names = 1相同。


选项2将永远不会在Linux上运行,因为该系统区分大小写。

在Linux和所有其他系统上,您需要使用选项1。



然后您的区分大小写问题就会结束。


I am using Hibernate and mySQL.

I develop the java application mostly on windows. All the tables are created with lowercase.

When I deployed it on the linux server, I noticed the tables are now in the proper casing (java naming convention). That's fine and all, but for some reason, one of my oneToMany List isn't loaded.

I am not using any other query except for "from "+class.getName()

I have tried changing the *lower_case_table_names=2* in my.conf so it matches in windows, however that didn't help.

Any other ideas?


Actually, that was stupid. It was my logic in the application that caused the problem, I was looking to do some partial fetching.

解决方案

You've selected the wrong option, a quote from the manual:
http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

lower_case_table_names =
0
Table and database names are stored on disk using the lettercase specified in the CREATE TABLE or CREATE DATABASE statement. Name comparisons are case sensitive. You should not set this variable to 0 if you are running MySQL on a system that has case-insensitive file names (such as Windows or Mac OS X). If you force this variable to 0 with --lower-case-table-names=0 on a case-insensitive file system and access MyISAM tablenames using different lettercases, index corruption may result.

1
Table names are stored in lowercase on disk and name comparisons are not case sensitive. MySQL converts all table names to lowercase on storage and lookup. This behavior also applies to database names and table aliases.

2
Table and database names are stored on disk using the lettercase specified in the CREATE TABLE or CREATE DATABASE statement, but MySQL converts them to lowercase on lookup. Name comparisons are not case sensitive. This works only on file systems that are not case sensitive! InnoDB table names are stored in lowercase, as for lower_case_table_names=1.

Option 2 will never work on Linux, because that system is case-sensitive.
On Linux and all other systems you need to use option 1.

Then your case sensitivity problems will be over.

这篇关于Hibernate不会在不同的操作系统下加载某个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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