hibernate映射 - 在运行hibernate配置时出错

时间:2015-05-08 09:00:22

标签: java oracle hibernate annotations hbm2ddl

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

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

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

配置: Eclipse Kepler SR2 Hibernate Core 4+ Oracle 10g JDK 8 for Eclipse

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;
    }

}

1 个答案:

答案 0 :(得分:0)

在@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;

}