Hibernate inside the table has a connection, query a table out Org.hibernate.HibernateException:HHH000142:Javassist enhancement failed: Table Contact class name exception

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.