gpt4 book ai didi

java - Spring hibernate CRUD : ORA-00923: FROM keyword not found where expected

转载 作者:行者123 更新时间:2023-11-30 02:53:48 24 4
gpt4 key购买 nike

我的代码中收到了“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;
}


}

最佳答案

问题出在@Column(name="PATIENT_ADDRESS_LINE 1")。难道数据库列实际上名为 PATIENT_ADDRESS_LINE_1

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

关于java - Spring hibernate CRUD : ORA-00923: FROM keyword not found where expected,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37844975/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com