How to properly convert List of specific objects to Gson?

后端 未结 3 900
野的像风
野的像风 2020-12-30 02:36

I am working on Spring MVC project. I am using Hibernate. I want to use AJAX with jQuery to get some JSONs from my Spring Controllers. Unfortunately when I was implementing

3条回答
  •  时光说笑
    2020-12-30 03:17

    As @madhead mentioned in the comments, this happens because, depending on the situation, Hibernate creates proxies around your object, which will call the actual implementation for some methods, and a "instrumented" one for others. Thus, the "actual" type of your objects are HibernateProxy. You can get access to your implementation by using a code similar to the one described here . In your case, you'd have to call the "unproxy" method for each item in your list, putting them into a new list.

提交回复
热议问题