org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleT

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.<init>(SessionFactoryImpl.java:385) 
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1769) 
at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:19) 
at util.HibernateUtil.<clinit>(HibernateUtil.java:13) 
... 1 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.<init>(EntityMetamodel.java:341) 
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:507) 
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:146) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163) 
... 6 more 
Caused by: java.lang.reflect.InvocationTargetException 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:135) 
... 15 more 
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for teamName in class set.Team
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:436) 
at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:200) 
at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:82) 
... 20 more 




这个异常不太好判断。 
Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister 
这个debug进去也不知道到底怎么回事。只知道是反射获取实体类对象时出了错。 


在网上查了一下, 大概有以下几种原因: 

1. 实体类的属性对象没有设置setter或者getter。 
http://stackoverflow.com/questions/18042247/could-not-get-constructor-for-org-hibernate-persister-entity-singletableentitype 

2. 没有导入javassist的jar文件  (javassist-3.15.0-GA.jar什么的) 
http://blog.csdn.net/xiaochangwei789/article/details/7712725 

3. 我这次出错的原因。 
我的实体类中的属性对象名和映射文件的property name不一致。 

private String team_name; 
<property name="team" column="team_name" type="string"/> 

这里只要改成: 
private String team_name; 
<property name="team_name"... 
就好了。 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值