Spring Boot Hibernate Syntax Error in SQL Statement
I had the exact same problem with an Order entity, solved defining explicitly the table name.
@Entity
@Table(name = "order_table")
class Order(
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid2")
val orderId: String,
val customerId: String,
...
)
Try change your Order
entity please:
package hello;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@Entity
@Table(name = "order_table")
public class Order {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private long id;
protected Order() {}
double amount;
@ManyToOne
Customer customer;
}
Explanation:
Pay attention on @Table
annotation. Using this annotation I've specified table name as order_table
. In your case by default hibernate tried to generate table order
. ORDER
is service word in any sql. Exception appeared because hibernate was generating *** statement for the order
table but db expected table name not service word order
.