Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to copy Java bean properties to another Java bean.

Sunil907-OracleOct 1 2015 — edited Oct 1 2015

Hi,

I want to copy java bean properties value from source bean to target bean. It may contain nested objects. to be very specific below is my Use case.

1. I have data fetched from database to JPA entities.

2. I have set of JAXB objects which will be used for web services.

3. I want to copy the object properties values from JPA entities to JAXB objects.

There are some options available to copy bean properties (using apache common), but problem is that it uses Shallow copy not deep copy. Package structures in source bean and target bean will be different and for nested beans also package structure will be different. Because of this, i can not used serialization  and deserialization mechanism to do the deep copy.

I am stuck here.  I want to use mapper type of concept which will contain source and target mapping bean properties.

On googling, i found that Dozer (http://dozer.sourceforge.net/documentation/usage.html) can be used for this purpose but i want to use some thing provided by Oracle.

Do we have any such type of framework provided by Oracle.

Please help.

Regards,

Sunil

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 29 2015
Added on Oct 1 2015
1 comment
584 views