Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

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!

JAXB clone or copy same block

ArsenchAug 1 2015

Hello all,

I need your help please. I’m generating an XML file using JAXB. The client request that I need to do is, when retrieving data (from data base) to set into JAXB objects I have to check one of the element values.

For example:

<id>123</id>
<Code>X22</Code>
<location>A1-2-3</location>
 

If the location value is as the above I have to change it to A1, A2 and A3 and set to location attribute cloning the block like example below.
First copy
<id>123</id>
<Code>X22</Code>
<location>A1</location>

Second copy
<id>123</id>
<Code>X22</Code>
<location>A2</location>

Third copy
<id>123</id>
<Code>X22</Code>
<location>A3</location>

All values stored in City object with getters and setters. The location type is String.

And set it into the same XML. My problem is that I can copy the blocks, but when I’m changing the location value it changes in all blocks, as I’m a beginner so please, help me if you can.

Many Thanks in advance.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 29 2015
Added on Aug 1 2015
0 comments
831 views