Spring数据JPA无法插入

Spring数据JPA无法插入

我的实体

import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.math.BigDecimal;

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

      @Id
      private String orderId;
      private Integer userId;
      private BigDecimal orderAmount;
      private BigDecimal despatchMoney;
      @Column(name = "`offer`")
      private BigDecimal offer;
      private Integer status;
      @Column(insertable = false, updatable = false)
      private java.sql.Timestamp createTime;
    }


我的资料库

import com.lhrsite.shop.entity.Order;
import org.springframework.stereotype.Repository;

@Repository
public interface OrderRepository extends BaseRepository<Order, String>         {
}

insert data
Order(orderId=1534511221253786, userId=1, orderAmount=0, despatchMoney=0, offer=0, status=0, createTime=null)


错误消息:

2018-08-17 21:07:01.257 WARN 1227 --- [nio-8088-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1064, SQLState: 42000
2018-08-17 21:07:01.257 ERROR 1227 --- [nio-8088-exec-4] o.h.engine.jdbc.spi.SqlExceptionHelper   : 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 order0_ where order0_.order_id='1534511221253786'' at line 1
2018-08-17 21:07:01.263 INFO 1227 --- [nio-8088-exec-4] o.h.e.internal.DefaultLoadEventListener  : HHH000327: Error performing load command : org.hibernate.exception.SQLGrammarException: could not


提取ResultSet

您如何解决这头大牛?

最佳答案

将表重命名为不同于订单的名称(例如,订单应该可以工作),订单是保留字。

关于java - Spring数据JPA无法插入,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51896337/

10-10 02:36