This question I learned hibernate when encountered, all kinds of methods have tried, two genius to find out, but not very deep learning. The feeling is that the relationship between the tables is not a problem.
Recently, someone asked me this question, he is the other can find out, but the sort of query on the exception, but also through my method to solve. So I've got it sorted out.
Published, hoping to help everyone.
WORKAROUND: 1. Add fetch= "Join" to the Many-to-one tag in the configuration file that configures the class this will also report an exception, but it can be queried.
2. Add lazy= "false" to the Many-to-one tag in the configuration file that configures this class, no delay loading, no problem
Exception Name:
11:00:26.288 [main] ERROR org.hibernate.proxy.pojo.javassist.javassistproxyfactory-hhh000142:javassist Enhancement Failed:com.zking.domain.Customer
JAVA.LANG.CLASSCASTEXCEPTION:COM.ZKING.DOMAIN.CUSTOMER_$$_JAVASSIST_0 cannot is cast to Javassist.util.proxy.Proxy
JUnit Display:
org.hibernate.HibernateException:HHH000142:Javassist Enhancement Failed:com.zking.domain.Customer
At Org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy (javassistproxyfactory.java:130)
...
Caused By:java.lang.classcastexception:com.zking.domain.customer_$$_javassist_0 cannot is cast to Javassist.util.proxy.Proxy
At Org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy (javassistproxyfactory.java:123)
... More
I know hibernate not deep, may say not very right, welcome in the comment area pointing, thank you!
Hibernate inside the table has a connection, query a table out Org.hibernate.HibernateException:HHH000142:Javassist enhancement failed: Table Contact class name exception