"Hibernate error" No serializer found for class Org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer "Get and load Difference"

Source: Internet
Author: User

Error:

 1  2  to create beanserializer (to avoid Exception, disable Serializationfeature.fail_on_empty_beans)) (through reference chain:com.agen.entity.product_$$_ jvst2a_3["Handler"]);  3   nested exception is Com.fasterxml.jackson.databind.JsonMappingException:No Serializer found for class Org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no  4  Properties discovered to create Beanserializer (to avoid exception, disable Serializationfeature.fail_on_empty_beans)) ( Through reference chain:com.agen.entity.product_$$_jvst2a_3["handler"]) 
View Code

This problem occurs because:

1 @ResponseBody2@RequestMapping ("/updateproduct")3 @Transactional4      PublicProduct UpdateProduct2 (product product) {5Product Product1 =Productservice.load (Product.getproductid ());6         if(Product1! =NULL){7 Product1.setproductname (Product.getproductname ());8 Product1.setproductcre (Product.getproductcre ());9         }Ten          One         returnProduct1; A}
View Code

The load () used in this method gets to this piece of data in the database.

When using Load (), enter bug mode to see that although you get to this data, but you want to see, but found that the display of the object's fields are null.

But there is a value in it!!

This returns to the foreground, the foreground does not receive the value, will run out the exception:

Modify:

So we should modify the load () method to the Get () method

1 /**2 * For product modification Operation3      * @return4      */5 @ResponseBody6@RequestMapping ("/updateproduct")7 @Transactional8      PublicProduct UpdateProduct2 (product product) {9Product Product1 =Productservice.get (Product.getproductid ());Ten         if(Product1! =NULL){ One Product1.setproductname (Product.getproductname ()); A Product1.setproductcre (Product.getproductcre ()); -         } -          the         returnProduct1; -}
View Code

This will solve the problem!!

"Hibernate error" No serializer found for class Org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer "Get and load Difference"

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.