注册Java Hibernate时发生异常。我该如何解决?

时间:2019-05-11 00:30:01

标签: java hibernate exception

运行我的程序只是为了列出某所大学的课程时,它会出现以下例外情况:

org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of Pessoa.id
    at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:119)
    at org.hibernate.engine.UnsavedValueFactory.getUnsavedIdentifierValue(UnsavedValueFactory.java:44)
    at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:41)
    at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:105)
    at org.hibernate.persister.entity.BasicEntityPersister.<init>(BasicEntityPersister.java:400)
    at org.hibernate.persister.entity.JoinedSubclassEntityPersister.<init>(JoinedSubclassEntityPersister.java:87)
    at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:58)
    at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:199)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
    at HibernateUtility.<clinit>(HibernateUtility.java:22)
    at ListaCursos.<init>(ListaCursos.java:12)
    at AplicacaoUniversidade.main(AplicacaoUniversidade.java:31)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.hibernate.property.BasicPropertyAccessor$BasicGetter.get(BasicPropertyAccessor.java:105)
    ... 11 more

我不知道从哪里开始求解,因为我只想列出课程,而且似乎该异常抱怨Person(Pessoa)类的id属性。 Person(Pessoa)类没有直接链接到Course(Curso)类。我注意到的另一件事是在此调用之后引发了异常

Session session = HibernateUtility.getSession();

有人可以帮我吗?

谢谢!

0 个答案:

没有答案