当我尝试使用@Table(" \" Employee \" ")批注时,它会生成异常。有以下例外

Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '" Employee "  (name, salary) values ('Jimmy', 35000)' at line 1


在不使用转义字符的情况下,employee表已成功生成,但是我想生成表名“ Employee”。

最佳答案

Hibernate作为JPA实现不仅是堆栈中的技术,它会影响数据库表名区分大小写的处理方式。数据库的容量以及如何建立起着至关重要的作用。

在MySQL中,表名的敏感度是通过lower_case_table_names系统变量控制的。例如,在Windows中,默认为小写名称,不区分大小写。同样,如果操作系统没有区分大小写的文件系统,那么结果就是表名不能区分大小写。

关于mysql - JPA 2:使用@Table批注的异常,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14519199/

10-14 19:54