commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Birgit Linner" <>
Subject [betwixt] mapID Problems
Date Tue, 17 Aug 2004 09:13:08 GMT
Hi everybody!

I`m new to betwixt and want to use it to dump and import our database
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 ----------------------------------
		<Person id="1"..... />
		<Projekt id="12"...>
        		<manager idref="13"/>   --> Reference to Person

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(...) ):

-------------------- ------------------------------------
StringReader xmlReader = new StringReader("dump.xml");
BeanReader beanReader = new BeanReader();
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.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 -----------------------------------------
  id     ="0"
  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!


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message