mysql - Hibernate 不会在不同的操作系统下加载某些表

标签 mysql windows linux hibernate

我正在使用 Hibernate 和 mySQL。

我主要在 Windows 上开发 Java 应用程序。所有表格均以小写字母创建。

当我将它部署到 Linux 服务器上时,我注意到表格现在处于正确的大小写中(Java 命名约定)。这很好,但是由于某种原因,我的 oneToMany 列表之一没有加载。

除了 "from "+class.getName()

我没有使用任何其他查询

我尝试更改 my.conf 中的 *lower_case_table_names=2* 以使其在 Windows 中匹配,但这没有帮助.

还有其他想法吗?


事实上,那是愚蠢的。导致问题的是我在应用程序中的逻辑,我想做一些部分提取。

最佳答案

你选错了,引自手册:
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.

选项 2 永远不会在 Linux 上运行,因为该系统区分大小写。
在 Linux 和所有其他系统上,您需要使用选项 1。

那么你的大小写问题就解决了。

关于mysql - Hibernate 不会在不同的操作系统下加载某些表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8739010/

相关文章:

mysql - Spring JPA 中跨两个不同数据库表的查询

mysql - 如何在 mac OSX 上更改 mysql $PATH?

python 2.7.9/pycharm 4/windows7 : 'file' object has no attribute 'readall'

c# - 如何 "enable ' 从与我的应用程序相同的位置下载先决条件'”

java - 在 Java/Eclipse 中运行批处理(shell/CMD)命令的最佳方法?

linux - 无法回显对文件所做的更改

android - 如何通过更改文件来切换手机的蓝牙状态?

mysql - 如何在 MySQL 存储过程中使用 DROP TABLE IF EXISTS

php - 注册表不起作用。 SQL发生错误

linux - 如何增量读取行