spring整合 hibernate 映射出问题

报错信息
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegist
Caused by: org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister
at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:185)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135)
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:389)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1799)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1870)
at org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.buildSessionFactory(LocalSessionFactoryBuilder.java:339)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:427)
at org.springframework.orm.hibernate4.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:412)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1612)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1549)
... 25 more
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:138)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:188)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:341)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:506)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:146)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163)
... 34 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:135)
... 43 more
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for emloyees in class com.imooc.employee.domain.Department
at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:316)
at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:310)
at org.hibernate.mapping.Property.getGetter(Property.java:321)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:444)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:200)
at org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:82)
... 48 more

实体类 一方package com.imooc.employee.domain;

import java.util.HashSet;
import java.util.Set;

public class Department {
private Integer did;
private String dname;
private String ddesc;

private Set<Employee> employees = new HashSet<Employee>();


public Integer getDid() {
    return did;
}
public Set<Employee> getEmployees() {
    return employees;
}
public void setEmployees(Set<Employee> employees) {
    this.employees = employees;
}
public void setDid(Integer did) {
    this.did = did;
}
public String getDname() {
    return dname;
}
public void setDname(String dname) {
    this.dname = dname;
}
public String getDdesc() {
    return ddesc;
}
public void setDdesc(String ddesc) {
    this.ddesc = ddesc;
}

}
多方
package com.imooc.employee.domain;

import java.util.Date;

public class Employee {
private Integer eid;
private String ename;
private String sex;
private Date birthday;
private Date joinDate;
private String eno;
private String username;
private String password;
private Department department;

public Integer getEid() {
    return eid;
}
public void setEid(Integer eid) {
    this.eid = eid;
}
public String getEname() {
    return ename;
}
public void setEname(String ename) {
    this.ename = ename;
}
public String getSex() {
    return sex;
}
public void setSex(String sex) {
    this.sex = sex;
}
public Date getBirthday() {
    return birthday;
}
public void setBirthday(Date birthday) {
    this.birthday = birthday;
}
public Date getJoinDate() {
    return joinDate;
}
public void setJoinDate(Date joinDate) {
    this.joinDate = joinDate;
}
public String getEno() {
    return eno;
}
public void setEno(String eno) {
    this.eno = eno;
}
public String getUsername() {
    return username;
}
public void setUsername(String username) {
    this.username = username;
}
public String getPassword() {
    return password;
}
public void setPassword(String password) {
    this.password = password;
}
public Department getDepartment() {
    return department;
}
public void setDepartment(Department department) {
    this.department = department;
}

}
配置文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">










    </set>
</class>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<class name="com.imooc.employee.domain.Employee" table="employee">
    <id name="eid" column="eid">
        <generator class="native" />
    </id>
    <property name="ename" column="ename" length="20" />
    <property name="sex" column="sex" length="10" />
    <property name="birthday" column="birthday" /> 
    <property name="joinDate" column="joinDate" /> 
    <property name="eno" column="eno" length="20" />
    <property name="username" column="username" length="20" />
    <property name="password" column="password" length="20" />
    <many-to-one name="department" class="com.imooc.employee.domain.Department" column="dno"/>
</class>


jar包为
antlr-2.7.7.jar
aopalliance-1.0.jar
asm-5.1.jar
aspectjweaver.jar
c3p0-0.9.5.2.jar
catalina.jar
classmate-1.3.0.jar
commons-fileupload-1.3.2.jar
commons-io-2.4.jar
commons-lang3-3.2.jar
commons-logging-1.1.3.jar
dom4j-1.6.1.jar
ehcache-2.10.3.jar
freemarker-2.3.23.jar
hibernate-commons-annotations-4.0.2.Final.jar
hibernate-core-4.2.21.Final.jar
hibernate-ehcache-4.2.18.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
jandex-2.0.3.Final.jar
javassist-3.18.1-GA.jar
jboss-logging-3.1.0.GA.jar
jboss-logmanager-2.0.4.Final.jar
jboss-transaction-api_1.1_spec-1.0.1.Final.jar
log4j-api-2.7.jar
log4j-core-2.7.jar
log4j-jboss-logmanager-1.1.2.Final.jar
mchange-commons-java-0.2.11.jar
mysql-connector-java-5.0.8.jar
ognl-3.1.12.jar
servlet-api.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.7.19.jar
spring-aop-4.0.0.RELEASE.jar
spring-aspects-4.0.0.RELEASE.jar
spring-beans-4.0.0.RELEASE.jar
spring-context-4.0.0.RELEASE.jar
spring-context-support-4.0.0.RELEASE.jar
spring-core-4.0.0.RELEASE-javadoc.jar
spring-core-4.0.0.RELEASE-sources.jar
spring-core-4.0.0.RELEASE.jar
spring-expression-4.0.0.RELEASE-javadoc.jar
spring-expression-4.0.0.RELEASE-sources.jar
spring-expression-4.0.0.RELEASE.jar
spring-jdbc-4.0.0.RELEASE.jar
spring-orm-4.0.0.RELEASE-javadoc.jar
spring-orm-4.0.0.RELEASE-sources.jar
spring-orm-4.0.0.RELEASE.jar
spring-struts-3.2.0.RELEASE.jar
spring-test-4.0.0.RELEASE.jar
spring-tx-4.0.0.RELEASE-javadoc.jar
spring-tx-4.0.0.RELEASE-sources.jar
spring-tx-4.0.0.RELEASE.jar
spring-web-4.0.0.RELEASE-javadoc.jar
spring-web-4.0.0.RELEASE-sources.jar
spring-web-4.0.0.RELEASE.jar
struts2-convention-plugin-2.5.10.jar
struts2-core-2.5.10.jar
struts2-spring-plugin-2.5.10.jar
xwork - jar.jar
哪位大神能给看一下 问题出在哪里

1个回答

public Set getEmployees() {
return employees;
}
public void setEmployees(Set employees) {
this.employees = employees;
}

1 Department 这个类的配置文件,这个属性配置有问题,
2 一般都是list类型。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!