Trying to do something simple here. Take an Entity object and copy it's identically named properties to another bean.
You can do this with Apache commons
org.apache.commons.beanutils.BeanUtils.copyProperties(source,target)
but the issue here is that we may have some properties that are specific to the entity bean (metadata like created,lastUpdated, etc timestamps) that we don't want to copy to the target bean and Apache Commons BeanUtils does not support ignoring of properties. I was pushed in the direction of Spring BeanUtils
org.springframework.beans.BeanUtils.copyProperties(source,target,ignoreProperties)
Where ignoreProperties is an array of strings of the property name syou want to ignore. Now the issue seems to be when performing this property copy it nulls the properties of the source object! As the source object is an Entity object with a mandatory id field when the transaction is committed we get a HibernateException
org.hibernate.HibernateException: identifier of an instance {source} was altered from {originalId} to null
Anyone know a way around this or are you committed to using one or the other? Confusing to me why the commons librariy doesn't support ignoring properties while copying or why the springframework BeanUtils seems to perform a cut/paste instead of a copy/paste.