简体   繁体   English

Play 2.0 Framework - 保留表名

[英]Play 2.0 Framework - Reserved Table Name

I have created a model called Group which in turn should create the table group. 我创建了一个名为Group的模型,该模型又应该创建表组。 As a result the database evolutes with errors, saying the table name is a reserved word. 结果,数据库逐渐出错,称表名是保留字。 Due to the fact that my model/table name is a reserved word I would like to know if there is a way to keep my table named group. 由于我的模型/表名是一个保留字,我想知道是否有办法让我的表名为group。

Here is an example of my Group model (Play Framework 2.0): 以下是我的Group模型(Play Framework 2.0)的示例:

 @Entity public class Group extends Model { @Id private long id; @Required private String groupName; private static Model.Finder<Long,Group> find = new Model.Finder<Long,Group> (Long.class, Group.class); public Group() { } public Group(String groupName) { this.groupName = groupName; } /*** Getters & Setters ***/ public long getId() { return id; } public void setId(long id) { this.id = id; } public String getGroupName() { return groupName; } public void setGroupName(String groupName) { this.groupName = groupName; } } 

Any help would be greatly appreciated! 任何帮助将不胜感激!

Simple use 使用简单

@Entity
@Table(name="groupOfxxx")
public class Group {

Something which describes the table without a reserved word. 描述表没有保留字的东西。

Maybe this will help: 也许会有所帮助:

@Entity
@Table(name="`group`")
public class Group {

If not, try: 如果没有,请尝试:

@Entity
@Table(name="group")
public class Group {

If not, try: 如果没有,请尝试:

https://stackoverflow.com/a/1565765/952046 https://stackoverflow.com/a/1565765/952046

EDIT 编辑

MySQL docs says: MySQL文档说:

Most of the words in the table are forbidden by standard SQL as column or table names (for example, GROUP). 表中的大多数单词都被标准SQL禁止为列或表名(例如,GROUP)。

Furthermore : 此外

The identifier quote character is the backtick (“`”):

mysql> SELECT * FROM `select` WHERE `select`.id > 100;

So it should work. 所以它应该工作。 Maybe there's sth wrong with quotes - make sure you use tick mark ( \\``), not a single quote ( ' ). You can also try setting 也许引号有错误 - 请确保使用刻度线( \\``), not a single quote ( ' ). You can also try setting ). You can also try setting mysql> SET sql_mode='ANSI_QUOTES'; ). You can also try setting mysql> SET sql_mode ='ANSI_QUOTES'; . Check if you can create table named . Check if you can create table named group` from MySQL console. . Check if you can create table named从MySQL控制台. Check if you can create table named group`的. Check if you can create table named

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM