简体   繁体   English

休眠映射-运行休眠配置时出错

[英]hibernate mapping - getting an error while running the hibernate configuration

I am trying to run Hibernate configuration from eclipse and create DB structure out of it. 我正在尝试从Eclipse运行Hibernate配置,并从中创建数据库结构。 On running configuration I am getting the following exception: 在运行配置时,出现以下异常:

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

I used annotations to create hbm/pojo. 我使用批注来创建hbm / pojo。 Below is the code. 下面是代码。 Im not sure if im missing something. 我不确定我是否缺少某些东西。 Any help? 有什么帮助吗?

Configuration: Eclipse Kepler SR2 Hibernate Core 4+ Oracle 10g JDK 8 for Eclipse 配置:Eclipse Kepler SR2 Hibernate Core 4+用于Eclipse的Oracle 10g 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;
    }

} }

Add below line after @Entity. 在@Entity之后添加以下行。

@Table(name="RuleQuestion")

The @Table annotation allows you to specify the details of the table that will be used to persist the entity in the database. @Table批注允许您指定用于将实体保留在数据库中的表的详细信息。

The @Table annotation provides four attributes, allowing you to override the name of the table, its catalogue, and its schema, and enforce unique constraints on columns in the table. @Table批注提供了四个属性,使您可以覆盖表的名称,目录和架构,并对表中的列实施唯一约束。 For now we are using just table name which is EMPLOYEE. 现在,我们仅使用表名称EMPLOYEE。

Also add the 同时添加

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

I have class that generate the Table 我有生成表格的类

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

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM