各位帮我一下,我的hibernate开始是可以用的(我开始映射它的时候,测试过的,可以用的.),后来不知道为什么不能用了..
CTempAlarm并又没有重复映射的....
13:08:45,062 DEBUG HbmBinder:1261 - Mapped property: alarmOrigInfo -> AlarmOrigInfo
%%%% Error Creating SessionFactory %%%%
org.hibernate.MappingException: Could not read mappings from resource: ytd/hib/C_Temp_Alarm/CTempAlarm.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 ytd.hib.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:69)
at ytd.hib.HibernateSessionFactory.getSession(HibernateSessionFactory.java:53)
at ytd.hib.C_Temp_Alarm.BaseHibernateDAO.getSession(BaseHibernateDAO.java:14)
at ytd.hib.C_Temp_Alarm.CTempAlarmDAO.save(CTempAlarmDAO.java:44)
at ytd.hib.C_Temp_Alarm.testMain.main(testMain.java:15)
Caused by: org.hibernate.DuplicateMappingException: Duplicate class/entity mapping ytd.hib.C_Temp_Alarm.CTempAlarm
at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:154)
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)
... 10 more
Exception in thread "main" java.lang.NullPointerException
13:08:45,062 ERROR CTempAlarmDAO:49 - save failed
java.lang.NullPointerException
at ytd.hib.C_Temp_Alarm.CTempAlarmDAO.save(CTempAlarmDAO.java:44)
at ytd.hib.C_Temp_Alarm.testMain.main(testMain.java:15)
at ytd.hib.C_Temp_Alarm.CTempAlarmDAO.save(CTempAlarmDAO.java:44)
at ytd.hib.C_Temp_Alarm.testMain.main(testMain.java:15)
------解决方法--------------------------------------------------------
是不是你在配置文件(*.xml)里面写了一个这个类的mapping ,
然后又在程序里面的配置(addResource)加了这个类啊?