学习hibernate出现的错误--之一(映射对应)

2021-06-23 00:03

阅读:456

标签:lua   map   more   jar   没有   完全   tar   配置文件   情况   

初学习遇见不少关于hibernate的错误,将这些错误一一记录下来。
java.lang.ExceptionInInitializerError
    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:422)
    at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:195)
    at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:244)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:241)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
    at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:110)
    at org.hibernate.tuple.entity.EntityTuplizerFactory.constructDefaultTuplizer(EntityTuplizerFactory.java:135)
    at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:80)
    at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:323)
    at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:475)
    at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:133)
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:84)
    at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:297)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385)
    at cn.ityuan.hibernate.sh.util.HibernateUtil.(HibernateUtil.java:14)
    ... 22 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:422)
    at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:107)
    ... 31 more
Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for description in class cn.ityuan.hibernate.sh.domain.User
    at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:328)
    at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:321)
    at org.hibernate.mapping.Property.getGetter(Property.java:304)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:299)
    at org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:158)
    at org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:77)
    ... 36 more
 
出现Caused by: org.hibernate.HibernateException: Unable to instantiate default tuplizer
有两种情况:
     

第一种情况:查阅资料说是缺少javassist.jar,而我的这个包是绝对没错的,重新加载了一还是不行。

第二种情况:查看映射文件,突然发现Could not find a getter for wineClass in class model.WineClass所以明白了,属性没有对应,说明映射文件和模型类中的属性对应有错,于是解决。
 
书写的持久化类和相应的配置文件的属性没有完全对应起来。
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

学习hibernate出现的错误--之一(映射对应)

标签:lua   map   more   jar   没有   完全   tar   配置文件   情况   

原文地址:http://www.cnblogs.com/BuleMouse/p/7163796.html


评论


亲,登录后才可以留言!