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

前端 未结 2 1387
滥情空心
滥情空心 2021-01-14 09:38

I have the follow script to create the table autolife.log:

CREATE TABLE `log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `idpoint` int(11) NOT NULL,
  `valu         


        
相关标签:
2条回答
  • 2021-01-14 09:59

    cool question. What about

    USE <Database Name>
    GO
    

    clause before executing script?

    Normally all SP, tables have those 2 lines before execution

    0 讨论(0)
  • 2021-01-14 10:09

    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 { ... }
    
    0 讨论(0)
提交回复
热议问题