首页新闻找找看学习计划

hibernate多对多映射出错,求大神帮忙看看。

0
悬赏园豆:200 [已解决问题] 解决于 2013-11-21 19:54

一、数据库建了三张表:表proleibie、proname、pro_name_leibie;

proleibie主键为lei_id、自增长

proname主键为pro_id、自增长

pro_name_leibie主键为id、自增长

截图如下:

————————————————————————————————---

————————————————————————————————————————

二、工程代码

   代码结构

  

    具体代码放到我网盘了,虽然很少,但如果粘贴这里来也太多,麻烦下载来看看。

    下载代码地址:http://pan.baidu.com/s/1049kK

三、错误提示:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: An association from the table pro_name_leibie refers to an unmapped class: Proleibie
    at org.hibernate.cfg.Configuration.secondPassCompileForeignKeys(Configuration.java:1299)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1217)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1333)
    at db.util.HibernateSessionUtil.<clinit>(HibernateSessionUtil.java:31)
    at db.test.leiTest.test2(leiTest.java:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
%%%% Error Creating SessionFactory %%%%
org.hibernate.InvalidMappingException: Could not parse mapping document from resource db/domain/Proname.hbm.xml
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:616)
    at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1635)
    at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1476)
    at db.util.HibernateSessionUtil.rebuildSessionFactory(HibernateSessionUtil.java:69)
    at db.util.HibernateSessionUtil.getSession(HibernateSessionUtil.java:53)
    at db.test.leiTest.test2(leiTest.java:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.DuplicateMappingException: Duplicate collection role mapping db.domain.Proname.pleibie
    at org.hibernate.cfg.Mappings.addCollection(Mappings.java:147)
    at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2085)
    at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2060)
    at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:381)
    at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:295)
    at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:166)
    at org.hibernate.cfg.Configuration.add(Configuration.java:716)
    at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:551)
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:613)
    ... 31 more
Java小伙的主页 Java小伙 | 初学一级 | 园豆:26
提问于:2013-11-20 18:38
< >
分享
最佳答案
0

<set>

  <many-to-many class="绝对路径才可以"></many-to-many>

</set> 

Java小伙 | 初学一级 |园豆:26 | 2013-11-21 19:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册