日期:2014-05-19  浏览次数:21206 次

在添加数据是出现:Unknown entity
整了老久了都没有发现是哪的问题:我是新手,麻烦高手指点一下

下面是错误代码:
具体的代码如下:
Java code
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)





Organization.hbm.xml

Java code


<?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>




action 代码:


Java code
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);
        }
}



application代码:

Java code
<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