xiaochao

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            1 隨筆 :: 6 文章 :: 48 評(píng)論 :: 0 Trackbacks

          最近學(xué)習(xí)Hiberante Annotations時(shí)遇到了該問題org.hibernate.MappingException: Unknown entity在baidu和googl上搜尋了 很久也沒有找到適合我的解決方法,最后發(fā)現(xiàn)是import Entity類造成的(使用Eclipse自動(dòng)提示導(dǎo)入的該包)

          import javax.persistence.Id;
          import javax.persistence.Table;
          import javax.persistence.Transient;
          import org.hibernate.annotations.Entity;//這是就出問題了哦

          @Entity
          @Table(name
          ="test_person")
          public class Person implements Serializable

          后面修改了引入的Entity

          import javax.persistence.Id;
          import javax.persistence.Table;
          import javax.persistence.Transient;
          import javax.persistence.Entity;//引入這個(gè)類就正確了

          @Entity
          @Table(name
          ="test_person")
          public class Person implements Serializable

          另外有些報(bào)org.hibernate.MappingException: Unknown entity,可能是沒有在cfg文件中加入 *.hbm.xml造成的

          posted on 2009-03-26 14:38 小超 閱讀(101207) 評(píng)論(27)  編輯  收藏 所屬分類: Hibernate

          評(píng)論

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2010-06-18 17:28 jj
          頂  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2010-07-20 21:38 yanick
          up  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2010-07-21 10:49 想學(xué)習(xí)
          我是這么 引用的 但是還是報(bào)的這個(gè)錯(cuò)誤 杯具  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意)[未登錄] 2010-11-27 01:54 test
          你使用了*.hbm.xml又用Annotations?  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2011-03-18 16:48 事實(shí)
          有用  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意)[未登錄] 2011-05-03 17:31 QQ
          大大太感謝你了@@  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2011-08-25 10:53 nidie
          加了注解怎么還要配置*.hbm.xml  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意)[未登錄] 2011-09-16 15:10 Terence
          @nidie
          不需要  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2011-09-18 00:18 zterry
          很感謝你啊,老實(shí)說,這問題困擾了我大半天,還是沒解決,看到你的文章太好了  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2011-12-07 18:27 mens moncler coats
          你的文章寫太好了  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2012-04-11 00:28 tregedie
          Mark!找到原因!感謝。  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意)[未登錄] 2012-12-22 00:10 lx
          沒有在cfg導(dǎo)入hbm  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意)[未登錄] 2013-01-09 14:19 111
          感激不盡那  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意)[未登錄] 2013-01-25 16:45 123
          太感動(dòng)了  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2013-05-04 11:43 東方失敗
          當(dāng)我們整合spring和hibernate時(shí),spring創(chuàng)建sessionFactory是通過的讀取hibernate的主文件直接獲得,拋出Unknown Entity多數(shù)都是 在hibernate中的主配置文件中沒有配置映射文件!!!!  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意)[未登錄] 2013-05-14 17:49 李寧
          我報(bào)的也是unkonw實(shí)體,但是問題是我根本就沒有牽涉到那兩個(gè)表啊!!怎么也會(huì)報(bào)這樣的錯(cuò)誤呢??  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意)[未登錄] 2013-06-27 09:52 新手
          我就是引用的javax.entity但是還是報(bào)這個(gè)錯(cuò)  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2013-07-16 14:18 小何
          遇到了該問題org.hibernate.MappingException: Unknown entity時(shí):
          首先要保證引入的包要正確:import javax.persistence.Entity;
          其次就是要配置hibernate.cfg.xml文件:
          <mapping class="com.aozhen.exchange.controller.model.GuaranteeService"/> 配置好模型的包路徑,多少個(gè)模型配置多少個(gè)mapping。  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2013-08-29 17:48 wang_ling_hui
          Unknown entity的問題倒是解決了,可是為什么必須得先在數(shù)據(jù)庫里創(chuàng)建表,不是不指定的話會(huì)自動(dòng)創(chuàng)建設(shè)嗎?  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2013-09-08 11:20 anonymous
          @lx
          終于找到了,果然是cfg文件里面的映射類忘了配置  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2013-09-17 16:06 夫人發(fā)熱
          你要引入那個(gè)persistent的那個(gè)包@新手
            回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2014-08-02 18:26 zhaolijin
          是的,配置文件有錯(cuò),又忘了在.cfg.xml中配置  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意)[未登錄] 2014-09-12 17:28 xx
          頂。。。。。。。。。。恍然大悟啊。。可憐我找了好幾天原因。  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2014-09-30 10:57 孫偉超
          org.hibernate.MappingException: Unknown entity: java.util.HashMap


          沒有配置錯(cuò)啊  回復(fù)  更多評(píng)論
            

          # org.hibernate.MappingException: Unknown entity: java.util.HashMap 2014-09-30 10:59 孫偉超
          怎么處理啊

          public boolean register(String username, String password) {
          Map<String, String> map = new HashMap<String, String>();
          map.put("username", username);
          map.put("password", password);
          return userDao.save(map);
          }




          package pojo;

          import javax.persistence.Column;
          import javax.persistence.Entity;
          import javax.persistence.GeneratedValue;
          import static javax.persistence.GenerationType.IDENTITY;
          import javax.persistence.Id;
          import javax.persistence.Table;

          /**
          * User entity. @author MyEclipse Persistence Tools
          */
          @Entity
          @Table(name = "user", catalog = "ssh")
          public class User implements java.io.Serializable {

          // Fields  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2015-09-20 14:37 冬眠
          太厲害了  回復(fù)  更多評(píng)論
            

          # re: org.hibernate.MappingException: Unknown entity常見問題(新手需注意) 2015-09-23 11:42 打的
          打的打  回復(fù)  更多評(píng)論
            


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 岱山县| 蒲城县| 临海市| 大安市| 枣庄市| 雅安市| 五峰| 普洱| 汶川县| 沙雅县| 和龙市| 博湖县| 佛学| 容城县| 江阴市| 邯郸市| 北安市| 鸡西市| 定襄县| 额敏县| 阿克| 江油市| 息烽县| 大方县| 淮安市| 金塔县| 崇州市| 长泰县| 新营市| 汨罗市| 屯门区| 监利县| 敖汉旗| 垦利县| 黎平县| 三原县| 乐亭县| 昆山市| 武汉市| 梁河县| 萨迦县|