- 浏览: 3368342 次
- 性别:
- 来自: 珠海
文章分类
- 全部博客 (1633)
- Java (250)
- Android&HTML5 (111)
- Struts (10)
- Spring (236)
- Hibernate&MyBatis (115)
- SSH (49)
- jQuery插件收集 (55)
- Javascript (145)
- PHP (77)
- REST&WebService (18)
- BIRT (27)
- .NET (7)
- Database (105)
- 设计模式 (16)
- 自动化和测试 (19)
- Maven&Ant (43)
- 工作流 (36)
- 开源应用 (156)
- 其他 (16)
- 前台&美工 (119)
- 工作积累 (0)
- OS&Docker (83)
- Python&爬虫 (28)
- 工具软件 (157)
- 问题收集 (61)
- OFbiz (6)
- noSQL (12)
最新评论
-
HEZR曾嶸:
你好博主,这个不是很理解,能解释一下嘛//左边+1,上边+1, ...
java 两字符串相似度计算算法 -
天使建站:
写得不错,可以看这里,和这里的这篇文章一起看,有 ...
jquery 遍历对象、数组、集合 -
xue88ming:
很有用,谢谢
@PathVariable映射出现错误: Name for argument type -
jnjeC:
厉害,困扰了我很久
MyBatis排序时使用order by 动态参数时需要注意,用$而不是# -
TopLongMan:
非常好,很实用啊。。
PostgreSQL递归查询实现树状结构查询
http://www.diybl.com/course/1_web/javascript/jsjs/20090415/165099.html
property 'delegate' has no getter method异常参考:http://panyongzheng.iteye.com/blog/1492278
解决办法
1.设置JSON-LIB让其过滤掉引起循环的字段。这个比较能解决问题,第2种方式只排除一个类,但是Hibernate会用到很多类,很难排除所有。
2.设置JSON-LIB的setCycleDetectionStrategy属性让其自己处理循环,省事但是数据过于复杂的话会引起数据溢出或者效率低下。
--------------------------------------------------------
一下是用到的三个类:
property 'delegate' has no getter method异常参考:http://panyongzheng.iteye.com/blog/1492278
解决办法
1.设置JSON-LIB让其过滤掉引起循环的字段。这个比较能解决问题,第2种方式只排除一个类,但是Hibernate会用到很多类,很难排除所有。
JsonConfig config = new JsonConfig(); config.setIgnoreDefaultExcludes(false); config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); config.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); config.setExcludes(new String[] {// 只要设置这个数组,指定过滤哪些字段。 "ctuAcademicStaffCcs", "ctuProjects"}); System.out.println(JSONSerializer.toJSON(list, config).toString());
2.设置JSON-LIB的setCycleDetectionStrategy属性让其自己处理循环,省事但是数据过于复杂的话会引起数据溢出或者效率低下。
JsonConfig config = new JsonConfig(); config.setIgnoreDefaultExcludes(false); config.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT); config.registerJsonValueProcessor(Date.class, new DateJsonValueProcessor("yyyy-MM-dd")); // date processor // register String tempStr = "{\"TotalRecords\":" + total.toString() + ",\"Datas\":" + JSONSerializer.toJSON(list, config).toString() + "}"; out.print(tempStr);
--------------------------------------------------------
一下是用到的三个类:
package com.common; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import net.sf.json.JsonConfig; import net.sf.json.processors.JsonValueProcessor; public class DateJsonValueProcessor implements JsonValueProcessor { public static final String Default_DATE_PATTERN = "yyyy-MM-dd"; private DateFormat dateFormat; public DateJsonValueProcessor(String datePattern) { try { dateFormat = new SimpleDateFormat(datePattern); } catch (Exception e) { dateFormat = new SimpleDateFormat(Default_DATE_PATTERN); } } public Object processArrayValue(Object value, JsonConfig jsonConfig) { return process(value); } public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) { return process(value); } private Object process(Object value) { return dateFormat.format((Date) value); } }
package com.common; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import net.sf.json.processors.*; public class HibernateJsonBeanProcessor implements JsonBeanProcessor { public JSONObject processBean(Object obj, JsonConfig jsonConfig) { return new JSONObject(); } }
package com.common; import net.sf.json.processors.*; import java.util.Set; import org.apache.log4j.Logger; public class HibernateJsonBeanProcessorMatcher extends JsonBeanProcessorMatcher { private static Logger log = Logger .getLogger(HibernateJsonBeanProcessorMatcher.class); @Override public Object getMatch(Class target, Set set) { System.out.println("@target.getName()="+target.getName()); if (target.getName().contains("$$EnhancerByCGLIB$$")) { log.warn("Found Lazy-References in Hibernate object " + target.getName()); return org.hibernate.proxy.HibernateProxy.class; } return DEFAULT.getMatch(target, set); } }
发表评论
-
TimeDifference.js获取时间差插件
2016-06-06 16:46 1129http://www.oschina.net/p/timedi ... -
日期时间插件Date-Utils
2016-05-28 23:16 1304原文 https://segmentfault.com/a/1 ... -
Riot v2.4.1 发布,JavaScript 的 MVP 框架
2016-05-23 13:14 949http://www.oschina.net/news/736 ... -
个最实用的JavaScript开发工具
2016-05-21 10:22 827http://my.oschina.net/u/2421687 ... -
zepto tap “点透”的解决
2016-05-20 15:44 1005http://my.oschina.net/u/2497925 ... -
spring配置事物的方式:注解和aop配置
2016-05-14 00:26 4066参考: Spring AOP中pointcut express ... -
写个mybatis的拦截插件,实现将所有执行的sql写入文件里
2016-05-12 15:59 5065原文 http://3131854.blog.51cto.co ... -
Mybatis分库分表扩展插件
2016-05-12 15:47 1589http://fangjialong.iteye.com/bl ... -
spring+mybatis+atomikos 实现JTA事务
2016-05-11 22:00 5476sping配置多个数据源 不同用户操作不同数据库 http:/ ... -
Date.js
2016-04-20 17:09 951原文 http://my.oschina.net/hnqing ... -
你真的了解图片的预加载吗
2016-04-14 10:26 1088http://my.oschina.net/HerrySun/ ... -
ibatis扩展支持主键生成的方法(非数据库方式)
2016-04-13 22:01 946http://blog.csdn.net/warison200 ... -
ibatis 动态 Mapped Statement
2016-03-31 17:02 824http://www.cnblogs.com/lcngu/p/ ... -
分布式事务管理
2016-03-31 16:43 1000http://my.oschina.net/pingpangk ... -
JavaScript之立即执行函数
2016-03-30 11:42 1194http://blog.csdn.net/qq83841923 ... -
JavaScript迭代
2016-03-27 01:44 712http://my.oschina.net/u/2346786 ... -
zepto(移动简化版jQuery),的 API 分类
2016-03-24 09:22 1701http://my.oschina.net/leejun200 ... -
[HTML5]Notification桌面提醒功能
2016-03-23 21:20 941[HTML5]Notification桌面提醒功能 http: ... -
ibatis中动态查询表返回用resultClass="java.util.HashMap" 的问题
2016-03-11 10:49 1085http://blog.csdn.net/dyllove98/ ... -
Mybatis传多个参数(三种解决方案)
2016-03-07 17:46 1403http://my.oschina.net/ydsakyclg ...
相关推荐
如果需要解析的数据间存在级联关系,而互相嵌套引用,在hibernate中极容易嵌套而抛出net.sf.json.JSONException: There is a cycle in the hierarchy异常。
并且对Dao和Service进行了封装,内含.jar包,并且解决了一对多双向关联的could not initialize proxy - no Session错误,同时解决了……invoked on net.sf.json.JSONException: There is a cycle in the hierarchy!...
解决这个启动 View Hierarchy时的这个bug: hierarchy viewer unable to debug device
Test of consistency is critical for the AHP methodology. When a pairwise comparison matrix (PCM) fails the consistency test, the decision maker (DM) needs to make revisions. The state of the art ...
本实例使用的是CXF框架通过main方法来进行发布WebService
the best way to understand how computers work is to build one from scratch, and this textbook leads students through twelve chapters and projects that gradually build a basic hardware platform and a ...
the cases in which there exists relationship between the ob- jects to be ranked, despite of the fact that such situations are very common in practice. For example, in web search, given a query certain...
Even when the actual handling differs, there is still some commonality. Hierarchical state machine design captures the commonality by organizing the states as a hierarchy. The states at the higher ...
A secondary goal of the book is to present mathematical tools just in time. Analysis techniques and proofs are presented as needed and in the proper context. In the past when the topics in this book ...
The Essential Qt 3.3 Class Hierarchy
Because this work is the rst attempt, combined with the author’s experience and knowledge being limited, if there is any improper place, please contact us. Contact method: E-mail: lfzh@suda.edu.cn,
An intent lock indicates that SQL Server wants to acquire a shared (S) lock or exclusive (X) lock on some of the resources lower down in the hierarchy. For example, a shared intent lock placed at the ...
The Application of AHP+LP in the Evaluation and Selection of Suppliers,BAI He-song,,This paper introduces the Supplier Relationship Management and the evaluation and selection of suppliers....
Virtually all the data structures are presented in the context of a single class hierarchy. This commitment to a single design allows the programs presented in the later chapters to build upon the ...
Memory Systems: Cache, DRAM, Disk is the fi rst book that takes on the whole hierarchy in a way that is consistent, covers the complete memory hierarchy, and treats each aspect in signifi cant detail....