Ok, so I recently started learning hibernate, and I got Netbeans 8.0 and started going through the official Netbeans hibernate tutorial: https://netbeans.org/kb/docs/web/hibernate-webapp.html
However, when I arrived at the bit where I was to test my HQL ("from Film" - the query I ran), I got this error:
Code:
java.lang.ClassCastException: dvdrental.Language_$$_javassist_60 cannot be cast to javassist.util.proxy.ProxyObject
There's a bunch of other stuff that follows that line, but that's not where I'm getting at.
The hibernate library I'm using came with Netbeans 8.0. So I went online, got the official Hibernate 4.3.6. I configured it on my netbeans, used it and got the same error.
Then I removed the javassist-3.18.1-GA.jar, and the error disappeared. I was able to run my HQL with no problems. Same with removing the javassist-3.15.0-GA.jar that comes with my netbeans - that took care of all my problems.
Which brings me to my question: is this supposed to happen? javassist-3.18.1-GA.jar is in the required folder. Why on earth would I get errors when using it and not get any errors when omitting it?
And why am I getting this error in the first place?
The full error is below. Thanks for your help, guys.
Code:
java.lang.ClassCastException: dvdrental.Language_$$_javassist_60 cannot be cast to javassist.util.proxy.ProxyObject
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:147)
at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:71)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:631)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3737)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:360)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:281)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1038)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:630)
at org.hibernate.type.EntityType.resolve(EntityType.java:438)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:139)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:982)
at org.hibernate.loader.Loader.doQuery(Loader.java:857)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2542)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.hql.classic.QueryTranslatorImpl.list(QueryTranslatorImpl.java:940)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)