gpt4 book ai didi

java - hibernate 映射 - 运行 hibernate 配置时出现错误

转载 作者:太空宇宙 更新时间:2023-11-04 13:52:58 25 4
gpt4 key购买 nike

我正在尝试从 eclipse 运行 Hibernate 配置并从中创建数据库结构。在运行配置时,我收到以下异常:

java.sql.SQLException: ORA-00942: table or view does not exist 
java.sql.SQLException: ORA-00904: : invalid identifier errors.

我使用注释来创建 hbm/pojo。下面是代码。我不确定我是否遗漏了一些东西。有什么帮助吗?

配置: eclipse 开普勒 SR2 hibernate 核心 4+甲骨文10g适用于 Eclipse 的 JDK 8

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
public class RuleQuestion {

//ATTRIBUTES
@Id
@GeneratedValue(strategy =GenerationType.AUTO)
private Long id;

//QUestion NAME On JSP

private String jspQuestion;

//LEVEL of Question in RULE DATA MODEL
private int level;
//IF QUESTION has CHILD questions associated with it
private boolean hasChildren;
//IS MULTISELECT
private boolean isMultiselect;
//POSSIBLE ANSWERS FOR QUESTION
/*@OneToMany(cascade = CascadeType.ALL, mappedBy = "question")
private List<RuleAnswer> possibleAnswers =new ArrayList<RuleAnswer>(0);
*///ANSWER for Question
private String answer;
//DEFEAULT ANSWER
private String defaultAnswer;
/*//ASSOCIATED CHILDREN QUESTIONS
private List<RuleQuestion> associatedQuestions;*/

//Visibility
private String visibility;

public RuleQuestion()
{

}


public Long getId() {
return id;
}


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


public String getJspQuestion() {
return jspQuestion;
}

public void setJspQuestion(String jspQuestion) {
this.jspQuestion = jspQuestion;
}

public int getLevel() {
return level;
}

public void setLevel(int level) {
this.level = level;
}

public boolean isHasChildren() {
return hasChildren;
}

public void setHasChildren(boolean hasChildren) {
this.hasChildren = hasChildren;
}

public boolean isMultiselect() {
return isMultiselect;
}

public void setMultiselect(boolean isMultiselect) {
this.isMultiselect = isMultiselect;
}

public String getAnswer() {
return answer;
}

public void setAnswer(String answer) {
this.answer = answer;
}

public String getDefaultAnswer() {
return defaultAnswer;
}

public void setDefaultAnswer(String defaultAnswer) {
this.defaultAnswer = defaultAnswer;
}

public String getVisibility() {
return visibility;
}

public void setVisibility(String visibility) {
this.visibility = visibility;
}

}

最佳答案

在 @Entity 之后添加以下行。

@Table(name="RuleQuestion")

@Table 注释允许您指定将用于将实体保存在数据库中的表的详细信息。

@Table 注释提供了四个属性,允许您覆盖表的名称、目录和架构,并对表中的列强制执行唯一约束。现在我们只使用表名 EMPLOYEE。

同时添加

  @Id
@GeneratedValue
@Column(name = "ID")
private Integer id;

我有生成表的类

@Entity
@Table(name = "TRANSACTION")
public class Transaction {

@Id
@GeneratedValue
@Column(name = "ID")
private Integer id;

@Column(name="OCPP_START_TAG_ID",nullable=false)
private String ocppStartTagId;

}

关于java - hibernate 映射 - 运行 hibernate 配置时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30119824/

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