0

I have this order entity. When I use an API to save order, it has this error:

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 'order (address, created_date, email, full_name, guid, phone_number, price, usern'

I don't know why it has an error. My schema still working alright. Please help me!

@Entity(name = "order")
public class Order {

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "order_id")
    @Id
    private int id;

    private String guid;

    @Column(name = "username")
    private String userName;

    @Column(name = "full_name")
    private String fullName;

    private String address;

    @Column(name = "phone_number")
    private String phoneNumber;

    private String email;

    private double price;

    @Column (name = "created_date")
    private Date createdDate;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "order")
    private List<OrderProduct> listProductOrders = new ArrayList<>();

}
2
  • 3
    I don't know why it has an error. - order is a reserved word in SQL context and it should be quoted Commented Dec 12, 2019 at 16:39
  • kindly print full exception trace. Commented Dec 12, 2019 at 16:51

1 Answer 1

1

order is a reserved word you need to provide a different name to your table.

Sign up to request clarification or add additional context in comments.

2 Comments

Then I must rename the table "order". :sosad:
No other option, faced the same issue :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.