java - Spring JPA无法使用单词 'match'作为数据库表的名称

标签 java mysql spring jpa

我创建实体

@Entity 
@Table(name = "MATCH") 
public class Match { 
...variables,getters and setters... 
}

在 MySQL 中,我有名为 match 的数据库表。

我还有JpaRepository

public interface MatchRepository extends JpaRepository<Match, Long>{
}

当我尝试使用 MatchRepository.findAll() 通过 Contoller 加载数据时,错误告诉我:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'match match0_' at line 1

有人可以解释一下为什么 MySQL 不允许我使用 match 之类的数据库表名称吗? 当我使用例如名称 match1 时,就可以了!

@Entity 
    @Table(name = "MATCH1") 
    public class Match { 
    ...variables,getters and setters... 
    }

为什么?! 我需要这个名称 match 因为我写的是关于足球的项目....

最佳答案

match是MySQL中的关键字,看看这个例子:

   SELECT MATCH(id, name, surname) AGAINST('milan')... 

要了解更多信息,请访问 link

关于java - Spring JPA无法使用单词 'match'作为数据库表的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34312651/

相关文章:

java - JPQL : result if Map<> contains specific or doesn't contain at all

mysql - 如何使用 GROUP BY 和 ORDER BY 优化查询

php - MySQLi 获取结果并创建键值数组

php - 具有与特定 id 匹配的多个 where 和 orWhere 子句的 Blade 查询

java - @SpringBootApplication 如何在 spring boot 中实际工作?

spring - Spring Boot中按内容类型缓存静态文件

spring - 在 spring jpa 实体中保存级联实体后缺失值

java - 如何在java中将json添加到http帖子的正文中

java - Java 中的 NTLM SSO 实现

java - GWT 应用程序在没有浏览器插件的情况下运行