commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Birgit Linner" <birgit.lin...@ovsag.de>
Subject AW: [betwixt] mapID Problems
Date Wed, 18 Aug 2004 14:14:05 GMT
Hi Robert!
Thank you for answering!

I really don't want to use digester rules ;-) But if I do not, I don't get
the ArrayLists back from BeanReader. The output shows, that the content is
read, but I get nothing back... only if I add digester rules. Looks like
otherwise the objects are "hanging in the air"..

Can the digester rules be the reason, why references are null and ids=0?

Thanks and a nice evening!

Birgit

-----Ursprungliche Nachricht-----
Von: robert burrell donkin [mailto:robertburrelldonkin@blueyonder.co.uk]
Gesendet: Dienstag, 17. August 2004 23:15
An: Jakarta Commons Users List
Betreff: Re: [betwixt] mapID Problems


hi Birgit

though you can mix digester rules with betwixt, this is an advanced
topic. i'd suggest that you'd be better letting betwixt do the whole of
your mapping initially.

if you want to vary your mapping of beans into elements, i'd suggest
reading up on dot betwixt files.

- robert

On 17 Aug 2004, at 10:13, Birgit Linner wrote:

> Hi everybody!
>
> I`m new to betwixt and want to use it to dump and import our database
> tables.
> Dumping is ok, altough I have some questions, too.
> The problem is, that every reference to other objects is null when I
> read
> the XML file.
> ( I have defined:
> beanReader.getBindingConfiguration().setMapIDs(true); )
>
>
>
> I have the following structure in the XML File:
>
>
> ----------------------- dump.xml ----------------------------------
> <ArrayList>
> 	<ArrayList>
> 		<Person id="1"..... />
> 		...
> 	</ArrayList>
> 	...
> 	<ArrayList>
> 		<Projekt id="12"...>
>         		<manager idref="13"/>   --> Reference to Person
>      		</Projekt>
> 	</ArrayList>
> ---------------------------------------------------------------------
>
>
>
> I am reading the XML file with this Reader (btw: I`m also new to
> Digester
> and tried a bit to get the ArrayList structure out of the file, I got
> no
> result when only using beanReader.registerBeanClass(...) ):
>
>
>
> -------------------- Dumper.java ------------------------------------
> StringReader xmlReader = new StringReader("dump.xml");
> BeanReader beanReader = new BeanReader();
> beanReader.getXMLIntrospector().setWrapCollectionsInElement(false);
> beanReader.getXMLIntrospector().setAttributesForPrimitives(true);
> beanReader.getBindingConfiguration().setMapIDs(true);
> beanReader.registerBeanClass("ArrayList", ArrayList.class);
> beanReader.addObjectCreate("ArrayList/ArrayList", ArrayList.class);
> beanReader.addSetNext("ArrayList/ArrayList", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Person",
> Person.class);
> beanReader.addSetNext("ArrayList/ArrayList/Person", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Role", Role.class);
> beanReader.addSetNext("ArrayList/ArrayList/Role", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Arbeitszeit",
> Arbeitszeit.class);
> beanReader.addSetNext("ArrayList/ArrayList/Arbeitszeit", "add");
> beanReader.registerBeanClass("ArrayList/ArrayList/Projekt",
> Projekt.class);
> beanReader.addSetNext("ArrayList/ArrayList/Projekt", "add");
> Object result = beanReader.parse(new File("dump.xml"));
> -----------------------------------------------------------------------
> -
>
>
> With this configuration I get an ArrayList with ArrayLists.. and so on,
> but - how mentioned above - the idref is null:
>
>
> ---------------------- OUTPUT -----------------------------------------
> Projekt:
>   id     ="0"
>   manager=null
>   name   ="Projekt1"
> -----------------------------------------------------------------------
>
> Is there anything I forgot? Or am I doing something wrong? I`d really
> appreciate a tip!
>
>
> Another question about wrinting a bean to XML:
> I`d like to rename my ArrayLists (only for better reading), e.g. the
> root-ArrayList to "Data" and the inner ones to "persons", "project"
> etc.
> Is this possible? I tried, but always get empty tags (also with using
> class-property in element-tag). But this is only "nice to have"...
>
> Thanks in advance!
>
> Have a nice day!
>
> Birgit
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message