Re: [Simple-support] Help with @Replace
Brought to you by:
niallg
|
From: Emilio C. da P. <ecd...@gm...> - 2012-01-24 16:13:05
|
This thread http://old.nabble.com/Creating-a-%22short%22-serialization-td14220229.html helped me, particularly this message http://old.nabble.com/Creating-a-%22short%22-serialization-td14220229.html#a14263846. But I still wonder why not allow the replacement of the root schema class... On Mon, Jan 23, 2012 at 9:15 PM, Emilio Carlos da Palma <ecd...@gm...> wrote: > I've found that calling the Called#replace method in the > Composite#write solves my problem (or works like I think it should). > Here is the snippet: > > core.Composite.java (around line 1018) > ... > } else { > source = caller.replace(source); > caller.persist(source); > write(node, source, schema); > } > ... > > But I don't know about what can be broken with this change. Maybe > replace should be called after persist, I don't know. In fact I think > I could use the @Persist, but I want to keep the original object. > > Emilio > > > On Mon, Jan 23, 2012 at 7:44 PM, Emilio Carlos da Palma > <ecd...@gm...> wrote: >> I can't get the annotated method to get called when serializing. >> >> Here is the code: >> >> Solution.java: >> >> @Root >> public class Solution >> >> @Element >> private String mId; >> >> @Element(required=false) >> private String name >> >> @ElementList >> private List<Dependent> mDependents; >> ... >> // (Constructors, getters/setters) >> ... >> @Replace >> public Solution replaceSolution() { >> return new Solution(mId, null, mDependents); >> } >> } >> >> Dependent.java: >> @Root >> public class Dependent >> >> @Element >> private String mId; >> >> @Element(required=false) >> private String name >> >> ... >> >> } >> >> What I intend is exclude the Solution#name element from the xml. >> >> Any hint? I tried some trunk versions back to 1200, but no success. >> >> Thanks in advance. >> >> Emilio |