日期:2014-05-19 浏览次数:21206 次
org.springframework.orm.hibernate3.HibernateSystemException: Unknown entity: com.oa.model.Organization$$EnhancerByCGLIB$$40141085; nested exception is org.hibernate.MappingException: Unknown entity: com.oa.model.Organization$$EnhancerByCGLIB$$40141085 org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:676) org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412) org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424) org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:694) com.oa.dao.imp.OrgDaoImp.addOrg(OrgDaoImp.java:15)
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="com.oa.model.Organization" table="t_organization"> <id name="id"> <generator class="native"/> </id> <property name="name"/> <property name="sn"/> <property name="description"/> <many-to-one name="parent" column="pid"></many-to-one> <set name="children" > <key column="pid"></key> <one-to-many class="com.oa.model.Organization"/> </set> </class> </hibernate-mapping>
package com.oa.web; import javax.annotation.Resource; import com.oa.model.Organization; import com.oa.service.OrgService; public class OrgAction { @Resource OrgService orgService; private Organization organization; public Organization getOrganization() { return organization; } public void setOrganization(Organization organization) { this.organization = organization; } public void add() { this.orgService.addOrg(this.organization,0); } }
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /> <property name="url" value="jdbc:sqlserver://localhost:1433;DataBaseName=moa" /> <property name="username" value="sa" /> <property name="password" value="yczn" /> <!-- 连接池启动时的初始值 --> <property n