Spring Hibernate CRUD:ORA-00923:找不到FROM关键字

时间:2016-06-15 20:17:14

标签: java spring oracle hibernate spring-mvc

我一直在接收" ORA-00923:FROM关键字未找到预期位置"我的代码中出错。我正在尝试使用Spring Hibernate实现CRUD操作。我已经检查过语法错误以及我的SQL查询中的引号,但似乎无法检测到任何异常情况。

用户类:

package com.spring.model;

import javax.persistence.*;

@Entity
@Table(name="PATIENT_MODEL")
public class User {

private int id;
private String patientFirstName;
private String patientLastName;
private String patientEmail;
private String patientAddress1;
private String patientAddress2;

@Id
@GeneratedValue
@Column(name="PATIENT_ID")
public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

@Column(name="PATIENT_FIRST_NAME")
public String getPatientFirstName() {
    return patientFirstName;
}

public void setPatientFirstName(String patientFirstName) {
    this.patientFirstName = patientFirstName;
}

@Column(name="PATIENT_LAST_NAME")
public String getPatientLastName() {
    return patientLastName;
}

public void setPatientLastName(String patientLastName) {
    this.patientLastName = patientLastName;
}

@Column(name="PATIENT_EMAIL_ADDRESS")
public String getPatientEmail() {
    return patientEmail;
}

public void setPatientEmail(String patientEmail) {
    this.patientEmail = patientEmail;
}

@Column(name="PATIENT_ADDRESS_LINE 1")
public String getPatientAddress1() {
    return patientAddress1;
}

public void setPatientAddress1(String patientAddress1) {
    this.patientAddress1 = patientAddress1;
}

@Column(name="PATIENT_ADDRESS_LINE_2")
public String getPatientAddress2() {
    return patientAddress2;
}

public void setPatientAddress2(String patientAddress2) {
    this.patientAddress2 = patientAddress2;
}


}

1 个答案:

答案 0 :(得分:2)

问题是@Column(name="PATIENT_ADDRESS_LINE 1")。可能是数据库列实际上名为PATIENT_ADDRESS_LINE_1

如果您确实需要使用名称中包含一个或多个空格的列,则需要指示Hibernate为quote列名称。另请参阅Oracle documentation.