Joy
Joy

Reputation: 71

How to ignore some fields in an object using BeanUtils.copyProperties in Spring Mvc

I'm using spring 4.1 version in my project. I have a bean with data which i want to copy to another bean with some fields ignored. I tried to copy like this...

BeanUtils.copyProperties(product, ecmProduct, String productName);

Here productName is the field which i want to ignore while copying. But by giving Ctrl+Space i'm getting suggestion as BeanUtils.copyProperties(Object, Object). ie, i'm unable to pass the field which is to be ignored, which results in error.

Can anyone please help me to solve this issue. Many thanks in advance...

Upvotes: 1

Views: 13326

Answers (1)

asg
asg

Reputation: 2456

BeanUtils of Spring 4.1 supports the feature of ignoring fields during copying the properties. Take a look here for details of the method.

Just confirm that you are using correct BeanUtils from Spring dependency itself.

Upvotes: 5

Related Questions