Bean复制的几种性能比较

    常用的bean复制属性的实现方式有:分别为Apache的BeanUtils和PropertyUtils,Spring的BeanUtils,Cglib的BeanCopier。

apche BeanUtils

    BeanUtils.copyProperties(dest,orig);

PropertyUtils

 PropertyUtils.copyProperties(dest,orig)

这两者的区别在与,PropertyUtils在拷贝对象时没有类型的转换,而BeanUtils已经包含了类型转换。

转换的支持常用的类型,但是java.util.Date类型除去。

spring BeanUtils

 org.springframework.beans.BeanUtils.copyProperties(frombean,
                        toBean)

cglib对象属性拷贝

BeanCopier bc = BeanCopier.create(FromBean.class, ToBean.class,
                    false);

bc.copy(orig,dest,null);

关于这几种对象属性的拷贝性能,请查考

http://www.cnblogs.com/kaka/archive/2013/03/06/2945514.html

猜你喜欢

转载自liuwuhen.iteye.com/blog/2282955
今日推荐