<tfoot id='EnDjJ'></tfoot>

    • <bdo id='EnDjJ'></bdo><ul id='EnDjJ'></ul>
    1. <legend id='EnDjJ'><style id='EnDjJ'><dir id='EnDjJ'><q id='EnDjJ'></q></dir></style></legend>

        <i id='EnDjJ'><tr id='EnDjJ'><dt id='EnDjJ'><q id='EnDjJ'><span id='EnDjJ'><b id='EnDjJ'><form id='EnDjJ'><ins id='EnDjJ'></ins><ul id='EnDjJ'></ul><sub id='EnDjJ'></sub></form><legend id='EnDjJ'></legend><bdo id='EnDjJ'><pre id='EnDjJ'><center id='EnDjJ'></center></pre></bdo></b><th id='EnDjJ'></th></span></q></dt></tr></i><div id='EnDjJ'><tfoot id='EnDjJ'></tfoot><dl id='EnDjJ'><fieldset id='EnDjJ'></fieldset></dl></div>

        <small id='EnDjJ'></small><noframes id='EnDjJ'>

      1. 休眠 - 回滚:org.hibernate.MappingException:未知实体

        Hibernate - Rollback: org.hibernate.MappingException: Unknown entity(休眠 - 回滚:org.hibernate.MappingException:未知实体)
          • <bdo id='XyzJP'></bdo><ul id='XyzJP'></ul>
            <legend id='XyzJP'><style id='XyzJP'><dir id='XyzJP'><q id='XyzJP'></q></dir></style></legend><tfoot id='XyzJP'></tfoot>

                <small id='XyzJP'></small><noframes id='XyzJP'>

                    <tbody id='XyzJP'></tbody>

                  <i id='XyzJP'><tr id='XyzJP'><dt id='XyzJP'><q id='XyzJP'><span id='XyzJP'><b id='XyzJP'><form id='XyzJP'><ins id='XyzJP'></ins><ul id='XyzJP'></ul><sub id='XyzJP'></sub></form><legend id='XyzJP'></legend><bdo id='XyzJP'><pre id='XyzJP'><center id='XyzJP'></center></pre></bdo></b><th id='XyzJP'></th></span></q></dt></tr></i><div id='XyzJP'><tfoot id='XyzJP'></tfoot><dl id='XyzJP'><fieldset id='XyzJP'></fieldset></dl></div>
                • 本文介绍了休眠 - 回滚:org.hibernate.MappingException:未知实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我编写了一些代码来将数据插入到我的 SQL 数据库中.实际上,我正在尝试使用 Hibernate 学习 Struts 2.但是,不幸的是,我在提交表单后遇到了问题.

                  I have written few codes for inserting data into my SQL database. Actually, I am trying to learn Struts 2 with Hibernate. But, unfortunately I am facing a problem after submitting my form.

                  我找不到此错误消息的原因.我的尝试catch 块抛出如下错误:

                  I could not find the reason for this error message. My try & catch block throws error like:

                  Exception in saveOrUpdate() Rollback  :org.hibernate.MappingException: Unknown entity: v.esoft.pojos.Employee
                  

                  Pojo(Employee.java):

                  Pojo(Employee.java):

                  @Entity
                  @Table(name = "employee", catalog = "eventusdb")
                  public class Employee implements java.io.Serializable {
                  
                      private Integer empId;
                      private String name;
                      private String website;
                  
                      public Employee() {
                      }
                  
                      public Employee(String name, String website) {
                          this.name = name;
                          this.website = website;
                      }
                  
                      @Id
                      @GeneratedValue(strategy = IDENTITY)
                      @Column(name = "emp_id", unique = true, nullable = false)
                      public Integer getEmpId() {
                          return this.empId;
                      }
                  
                      public void setEmpId(Integer empId) {
                          this.empId = empId;
                      }
                  
                      @Column(name = "name", nullable = false)
                      public String getName() {
                          return this.name;
                      }
                  
                      public void setName(String name) {
                          this.name = name;
                      }
                  
                      @Column(name = "website", nullable = false, length = 65535)
                      public String getWebsite() {
                          return this.website;
                      }
                  
                      public void setWebsite(String website) {
                          this.website = website;
                      }
                  
                  }
                  

                  还有Employee.hbm.xml:

                      <?xml version="1.0"?>
                  <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
                  <!-- Generated Sep 10, 2013 4:29:04 PM by Hibernate Tools 3.4.0.CR1 -->
                  <hibernate-mapping>
                      <class name="v.esoft.pojos.Employee" table="employee" catalog="eventusdb">
                          <id name="empId" type="java.lang.Integer">
                              <column name="emp_id" />
                              <generator class="identity" />
                          </id>
                          <property name="name" type="string">
                              <column name="name" not-null="true" />
                          </property>
                          <property name="website" type="string">
                              <column name="website" length="65535" not-null="true" />
                          </property>
                      </class>
                  </hibernate-mapping>
                  

                  推荐答案

                  如果实体没有被映射,你应该检查休眠配置.Hibernate 是用于将 pojo(实体)映射到数据库模式对象的 ORM 框架.您没有配置或休眠找不到对象 Employee 的映射.配置文件是 hibernate.cfg.xml 应该包含到资源 Employee.hbm.xml 的映射.假设此文件与 Employee 类位于同一文件夹中.然后映射将是

                  If the entity isn't mapped, you should inspect the hibernate configuration. Hibernate is ORM framework used to map pojos (entities) to the database schema objects. You didn't configure or hibernate couldn't find mapping for the object Employee. The configuration file is hibernate.cfg.xml should contain the mapping to the resource Employee.hbm.xml. Suppose this file is in the same folder as Employee class. Then the mapping will be

                  <mapping resource="v/esoft/pojos/Employee.hbm.xml"/>
                  

                  如果您使用基于注解的配置的另一种方法,那么您应该使用 class 属性映射到包含 Hibernate/JPA 注解的 pojo.

                  Another approach if you used an annotation based configuration, then you should use class attribute to map to the pojo that contains Hibernate/JPA annotations.

                  <mapping class="v.esoft.pojos.Employee"/>
                  

                  注意,基于注解的 Configuration 可能会根据 Hibernate 的版本而有所不同,并且可能需要额外的库.

                  Note, annotation based Configuration might be different depending on version of Hibernate and may require additional libraries.

                  这篇关于休眠 - 回滚:org.hibernate.MappingException:未知实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)
                  • <bdo id='xelh9'></bdo><ul id='xelh9'></ul>
                    1. <legend id='xelh9'><style id='xelh9'><dir id='xelh9'><q id='xelh9'></q></dir></style></legend>

                      <small id='xelh9'></small><noframes id='xelh9'>

                            <tfoot id='xelh9'></tfoot>
                              <tbody id='xelh9'></tbody>
                          • <i id='xelh9'><tr id='xelh9'><dt id='xelh9'><q id='xelh9'><span id='xelh9'><b id='xelh9'><form id='xelh9'><ins id='xelh9'></ins><ul id='xelh9'></ul><sub id='xelh9'></sub></form><legend id='xelh9'></legend><bdo id='xelh9'><pre id='xelh9'><center id='xelh9'></center></pre></bdo></b><th id='xelh9'></th></span></q></dt></tr></i><div id='xelh9'><tfoot id='xelh9'></tfoot><dl id='xelh9'><fieldset id='xelh9'></fieldset></dl></div>