JPA: MySQL says table don't exist, but it exist actually

六眼飞鱼酱① 提交于 2019-12-01 08:34:57

Case sensitivity of MySQL table names depends on operating system, I guess that's the cause:

In MySQL, databases correspond to directories within the data directory. Each table within a database corresponds to at least one file within the database directory (and possibly more, depending on the storage engine). Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database and table names. This means database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix. One notable exception is Mac OS X, which is Unix-based but uses a default file system type (HFS+) that is not case sensitive. However, Mac OS X also supports UFS volumes, which are case sensitive just as on any Unix.

So, you need to set table name in the correct case explicitly:

@Entity @Table(name = "log")
public class Log implements Serializable { ... }

cool question. What about

USE <Database Name>
GO

clause before executing script?

Normally all SP, tables have those 2 lines before execution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!