JPA:spring实体中的SQL语法出错

时间:2017-05-10 10:51:21

标签: java mysql spring jpa

我正在使用spring框架,当我创建FareRate实体时,它会给我以下错误

无法对JDBC目标执行模式管理[create table fare_rate(id bigint not null auto_increment,minimum varchar(255),moving varchar(255),starting varchar(255),primary key(id))]

您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在第1行的'starting varchar(255),primary key(id))'附近使用正确的语法

FareRate.class

@Entity
public class FareRate implements Serializable{
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String starting;

    private String moving;

    private String minimum;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getStarting() {
        return starting;
    }

    public void setStarting(String starting) {
        this.starting = starting;
    }

    public String getMoving() {
        return moving;
    }

    public void setMoving(String moving) {
        this.moving = moving;
    }

    public String getMinimum() {
        return minimum;
    }

    public void setMinimum(String minimum) {
        this.minimum = minimum;
    }
}

1 个答案:

答案 0 :(得分:3)

startingreserved keyword in MySQL。为列选择其他名称。