部分关键代码--------Subject.hbm.xml<id name="subjectId" type="java.lang.Integer"><column name="subjectID" /><generator class="native" /></id>------SubjectDao:public void delete(int persistentInstance) {log.debug("deleting Subject instance");try {getHibernateTemplate().delete(persistentInstance);//这是第57行log.debug("delete successful");} catch (RuntimeException re) {log.error("delete failed", re);throw re;}}-------SubjectBizpublic void deleteSubject(int subjectID){isubjectdao.delete(subjectID);//这是第75行}--------SubjectActionpublic String deleteSubject(){isubjectbiz.deleteSubject(subjectId);return SUCCESS;}--------Struts.xml<action name="deletesubjectByID" class="subjectaction" method="deleteSubject"><result name="success" type="redirect">/FenYeSubjectAction.action</result></action>我用的是Struts2,Hibernate,Spring框架做的老是报一下错误(精简下):org.hibernate.MappingException: Unknown entity: java.lang.Integerorg.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:78)org.hibernate.event.def.DefaultDeleteEventListener.onDelete(DefaultDeleteEventListener.java:52)org.hibernate.impl.SessionImpl.fireDelete(SessionImpl.java:766)org.hibernate.impl.SessionImpl.delete(SessionImpl.java:744)org.springframework.orm.hibernate3.HibernateTemplate$25.doInHibernate(HibernateTemplate.java:852)org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:846)org.springframework.orm.hibernate3.HibernateTemplate.delete(HibernateTemplate.java:842)com.dao.SubjectDAO.delete(SubjectDAO.java:57)com.biz.SubjectBiz.deleteSubject(SubjectBiz.java:75)这是什么情况啊,有没有大侠知道,指点一下.
2 回答
哔哔one
TA贡献1854条经验 获得超8个赞
看一下--------SubjectAction
public String deleteSubject(){
isubjectbiz.deleteSubject(subjectId);
return SUCCESS;
}
subjectId 是否是用struts2 自动从页面封装过来的 还是你使用request获取的 首先你输出一下有没有值 然后如果是request获取的 必须要把它转换成integer 其次如果有值 且为integer 这时你就要检查你的数据库隐射文件是否正确 一级一级排除
添加回答
举报
0/150
提交
取消