0
votes

I am using spring framework and when I am creating the FareRate Entity it gives me following error

Unable to execute schema management to JDBC target [create table fare_rate (id bigint not null auto_increment, minimum varchar(255), moving varchar(255), starting varchar(255), primary key (id))]

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 'starting varchar(255), primary key (id))' at line 1

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
Seems your JPA provider doesn't automatically quote SQL keywords, and so imposes on you that you either quote the column name, or change it to something else via @Column. Some JPA providers take care of this for you ... - Neil Stockton
Issue is solved Thanks @NeilStockton - SFAH

1 Answers

3
votes

starting is a reserved keyword in MySQL. Choose a different name for the column.