日期:2014-05-18  浏览次数:20712 次

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
jsp 中取出MAP 的值 如下解决思路