为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我向数据库中添加数据测试的时候总是报这个错误

Exception in thread "main" java.lang.ExceptionInInitializerError

at Test.Test.add(Test.java:33)

at Test.Test.main(Test.java:19)

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:399)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)

at util.HibernateUtil.<clinit>(HibernateUtil.java:27)

... 2 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:403)

at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:520)

at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:148)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:525)

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:57)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:525)

at org.hibernate.tuple.entity.EntityTuplizerFactory.constructTuplizer(EntityTuplizerFactory.java:135)

... 15 more

Caused by: org.hibernate.PropertyNotFoundException: Could not find a getter for grade in class entity.Student

at org.hibernate.property.BasicPropertyAccessor.createGetter(BasicPropertyAccessor.java:310)

at org.hibernate.property.BasicPropertyAccessor.getGetter(BasicPropertyAccessor.java:304)

at org.hibernate.mapping.Property.getGetter(Property.java:323)

at org.hibernate.tuple.entity.PojoEntityTuplizer.buildPropertyGetter(PojoEntityTuplizer.java:411)

at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:200)

at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:80)

... 20 more


正在回答

2 回答

entity包下的Student类的grade缺少get方法,

0 回复 有任何疑惑可以回复我~
Could not find a getter for grade in class entity.Student

这个不是写了在你的grade中没有student的getter方法

0 回复 有任何疑惑可以回复我~
#1

薛定谔de猫 提问者

public Set<Student> getStudents() { return students; } public void setStudents(Set<Student> students) { this.students = students; } 我看了,有getter方法啊
2017-06-30 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Hibernate初探之一对多映射
  • 参与学习       42171    人
  • 解答问题       295    个

Hibernate中一对多关联映射配置,以及cascade和inverse属性作用

进入课程

为什么我向数据库中添加数据测试的时候总是报这个错误

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信