【发布时间】:2013-01-09 06:18:43
【问题描述】:
当我尝试使用 @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
没有使用转义字符,员工表生成成功,但我想生成表名“员工”。
【问题讨论】:
-
只是出于好奇……为什么?
-
因为这样使用
@Table注解时,数据库中的表名是employee。但我想格式化数据库中的表名,如Employee。 -
您使用的是什么数据库?它可能不支持表名中的引号
-
为什么你想要'Employee'而不是'employee'?在大多数数据库系统中,表的名称不区分大小写
-
我知道,但是它的 JPA 2.0 规范,我想执行这个,这是例外情况,但有些时候想格式化表名。我为 OCE-JPA 认证做好准备
标签: mysql hibernate orm annotations jpa-2.0