Hibernate里使用jackjson出现异常解决办法
2014-01-04 19:33
411 查看
一.在把Hibernate里的持久化类集合List<House>用jackjson转成json格式时,因为持久化类里有一对多,多对一的映射关系,在转成json格式时会出现死循环
解决办法:
把House类里关联的类的set前上加上@JsonIgnore
二.加了@JsonIgnore还是出现了下面的异常
org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS)
) (through reference chain: java.util.ArrayList[0]->houserent.entity.House["users"]->houserent.entity.Users_$$_javassist_4["hibernateLazyInitializer"])
这异常好像是因为懒加载引起的
在House类里关联的类前面加上@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
参考http://www.linuxso.com/architecture/26599.html
解决办法:
把House类里关联的类的set前上加上@JsonIgnore
二.加了@JsonIgnore还是出现了下面的异常
org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS)
) (through reference chain: java.util.ArrayList[0]->houserent.entity.House["users"]->houserent.entity.Users_$$_javassist_4["hibernateLazyInitializer"])
这异常好像是因为懒加载引起的
在House类里关联的类前面加上@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
参考http://www.linuxso.com/architecture/26599.html
相关文章推荐
- 关于json-lib 和hibernate一起使用的时候出现死循环的解决办法
- 使用getHibernateTemplate()的方法时出现空指针异常的解决办法
- fastjson序列化hibernate代理和延迟加载对象出现no session异常的解决办法
- 使用hql使用order by子句出现异常和数据异常的解决办法org.hibernate.hql.internal.ast.QuerySyntaxException
- fastjson序列化hibernate代理和延迟加载对象出现no session异常的解决办法
- fastjson在使用hibernate关系模型转json出现$ref解决办法
- fastjson在使用hibernate关系模型转json出现$ref解决办法
- fastjson序列化hibernate代理和延迟加载对象出现no session异常的解决办法
- 关于json-lib 和hibernate一起使用的时候出现死循环的解决办法
- 使用JSONObject.fromObject的时候出现“There is a cycle in the hierarchy”异常 的解决办法
- myeclipse 使用weblogic10启动hibernate项目时出现ClassNotFoundException: org.hibernate.hql.ast.HqlToken异常的解决办法
- boost使用property_tree/json_parser处理包含中文字符的UTF8时异常的解决办法
- Spring中使用proxool连接池的配置方式与出现Attempt to refer to a unregistered pool by its alias 'ums'异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 使用Android SDK Manager下载sdk时总是出现中断异常的解决办法。
- 关于使用Hibernate出现的多种常见错误的原因及解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 使用json发生java.lang.NoClassDefFoundError: net/sf/json/JSONObject异常的解决办法
- 序列化hibernate代理和延迟加载对象出现no session异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法