MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » org.hibernate.MappingException: Could not read m

org.hibernate.MappingException: Could not read mappings from resource:

www.MyException.Cn  网友分享于:2013-11-27  浏览:2735次
hibernate 映射问题!
<set name="putups" inverse="true">
  <key>
  <column name="ROOMID" not-null="true" />
  </key>
  <one-to-many class="mypack.Putup" />
  </set>
我把双向映射加上就有下面的错误:

org.hibernate.PropertyNotFoundException: Could not find a getter for putups in class mypack.Room
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:282)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:275)
at org.hibernate.mapping.Property.getGetter(Property.java:260)
at org.hibernate.tuple.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:255)
at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:121)
at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:257)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:412)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:216)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1176)
at HibernateUtil.HibernateSessionFactory.<clinit>(HibernateSessionFactory.java:31)
at mypack.RoomDAO.saveroom(RoomDAO.java:7)
at mypack.RoomDAO.main(RoomDAO.java:20)
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: Could not read mappings from resource: mypack/Room.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at HibernateUtil.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69)
at HibernateUtil.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53)
at mypack.RoomDAO.saveroom(RoomDAO.java:7)
at mypack.RoomDAO.main(RoomDAO.java:20)
Caused by: org.hibernate.DuplicateMappingException: Duplicate collection role mapping mypack.Room.putups
at org.hibernate.cfg.Mappings.addCollection(Mappings.java:124)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2030)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2005)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:368)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:282)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
at org.hibernate.cfg.Configuration.add(Configuration.java:386)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:427)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 9 more
Exception in thread "main" java.lang.NullPointerException
at mypack.RoomDAO.saveroom(RoomDAO.java:9)
at mypack.RoomDAO.main(RoomDAO.java:20)

------解决方案--------------------
你的mypack.Room 类里没有putups变量或者该变量没有定义getPutups方法
------解决方案--------------------
Could not find a getter for putups in class mypack.Room
检查下你的PO

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有