com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception:使用spring boot和jpa的“字段列表”中的未知列“”

mwkjh3gx  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(268)

我一整天都在用头撞这个,但好像没把它弄好。。。我相信你们中的一些人会看到这一点,马上知道答案。
在mysql数据库中,我有一个表 RFQ_HEADER 有主键的 rfq_no . 我还有一张table line_item 它的复合主键由 rfq_fk 以及 item_no 细节
rfqheader类

@Entity
@Table(name = "rfq_header")
public class RfqHeader implements Serializable  {
private static final long serialVersionUID = 1L;

@Id @Column(name = "rfq_no")                    private String rfqNo;
@NotBlank @Column(name = "cust_no")             private String custNo; 
@NotBlank @Column(name = "terms_code")          private String termsCode; 
@Temporal(TemporalType.DATE)
@NotBlank @Column(name = "rfq_datetime")        private Date receivedDate; 
@Temporal(TemporalType.DATE)
@Column(name = "due_datetime")                  private Date dueDate; 
@Temporal(TemporalType.DATE)
@Column(name = "acknow_datetime")               private Date acknowlegementDate; 
@Column(name = "mu_percent")                    private Double muPercent; 
@Column(name = "file_label")                    private String finalLabel;
@NotBlank @Column(name = "sent_by")             private String sentBy;
@NotBlank @Column(name = "fob")                 private String fob;
@NotBlank @Column(name = "ship_method")         private String shipMethod;
@Column(name = "notes")                         private String notes;
@Column(name = "internal_notes")                private String internalNotes;
@Column(name = "rfq_closed")                    private String rfqClosed;
@Column(name = "reason_closed")                 private String reasonClosed;
@Column(name = "qs_rfq_no")                     private String qsRfqNo;

@OneToMany(targetEntity=LineItem2.class, mappedBy="primaryKey.header2",fetch=FetchType.LAZY, cascade=CascadeType.ALL)
private Set<LineItem2> lineItems2;

...getters/setters/constructors

可嵌入类-lineitem2pk

@Embeddable
public class LineItem2Pk implements Serializable{

private static final long serialVersionUID = 1L;

@Column(name="rfq_pk",insertable=false, updatable=false)
private String rfqPk;
@Column(name="item_no",insertable=false, updatable=false)
private String itemNo;

@ManyToOne
@JoinColumn(name="rfq_no", unique=true, updatable=false, insertable=false, nullable=false )
private RfqHeader header2;

...getters/setters/constructors

lineitem2类

@Entity
@Table(name="line_item")
public class LineItem2 implements Serializable{

private static final long serialVersionUID = 1L;

@EmbeddedId 
private LineItem2Pk primaryKey;

@Column(name="part_no")                         private String partNo;
@Column(name="quantity")                        private int quantity;
@Column(name="price_quoted")                    private double priceQuoted;
@Column(name="notes")                           private String notes;
@Column(name="internal_notes")                  private String internalNotes;
...getters/setters/constructors

控制台日志错误

com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception:“字段列表”中的未知列“lineitem2x0.header2\u rfq\u no”

Hibernate: select lineitem2x0_.header2_rfq_no as header8_0_, 
lineitem2x0_.item_no as item_no1_0_, lineitem2x0_.rfq_pk as rfq_pk2_0_, 
lineitem2x0_.internal_notes as internal3_0_, lineitem2x0_.notes as 
notes4_0_, lineitem2x0_.part_no as part_no5_0_, lineitem2x0_.price_quoted as 
price_qu6_0_, lineitem2x0_.quantity as quantity7_0_ from line_item 
lineitem2x0_ where lineitem2x0_.rfq_pk=?
2018-06-06 21:44:03.789  WARN 12424 --- [nio-8080-exec-1] 
o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Error: 1054, SQLState: 42S22
2018-06-06 21:44:03.789 ERROR 12424 --- [nio-8080-exec-1] 
o.h.engine.jdbc.spi.SqlExceptionHelper   : Unknown column 
'lineitem2x0_.header2_rfq_no' in 'field list'
2018-06-06 21:44:03.793 ERROR 12424 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/]. 
[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] 
in context with path [] threw exception [Request processing failed; nested 
exception is 
org.springframework.dao.InvalidDataAccessResourceUsageException: could not 
extract ResultSet; SQL [n/a]; nested exception is 
org.hibernate.exception.SQLGrammarException: could not extract ResultSet] 
with root cause

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 
'lineitem2x0_.header2_rfq_no' in 'field list'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~ 
[na:1.8.0_171]

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题