problem in Beanutils.copyProperties()

R

Rahul

Hi all,

I am having a problem in using copyProperties() of
org.apache.commons.beanutils.BeanUtils class

I am doing it in this way

BeanUtils.copyProperties(destBean,srcBean)

where destBean and srcBean both have a property by name date,

which is of type java.sql.Timestamp()

If date property of srcBean is set to null then the above statement
gives

an exception: "BeanUtil.ConversionException: No value specified"

It works fine in case srcBean.date is properly initialized.

But there is a possibility of having null in srcBean.date in my code.

So, how to deal with this?
 
R

Roedy Green

where destBean and srcBean both have a property by name date,

which is of type java.sql.Timestamp()

My reaction is that is a very dangerous way to copy a single field.
You could inadvertently copy other fields as well that just happened
to have the same name.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top