Well, I know you can do the following to remove the betwixt id ... beanWriter.getBindingConfiguration().setMapIDs(false);
Then if you want to make the getId() value of your bean an attribute ... beanWriter.getXMLIntrospector().getConfiguration().setAttributesForPrimitive s(false); or if you don't want to make all primitive values attribute as the above will do ... in a .betwixt file write ... <?xml version='1.0' encoding='UTF-8' ?> <info> <element name='YourElementName'> <attribute name='id' property='Id'/> <addDefaults/> </element> </info> There ways to do this by code but, not familar with that approach. J -----Original Message----- From: Christian Aust [mailto:[EMAIL PROTECTED] Sent: Friday, January 07, 2005 1:24 PM To: Jakarta Commons Users List Subject: Re: [betwixt] How can I make betwixt accept any attribute "id" as an element id? Hi Jason, Am 07.01.2005 um 18:10 schrieb Jason Wood: > do you want to make the id your from your bean an attribute or id the > betwixt generated? instead of making up some id value, betwixt should simply stick with the id value that the object already provides. In other words: If a bean property "id" exists, it should be converted into an XML attribute "id" that will be referenced using "idref" if necessary. ====================================================================== public class Member { public long getId() public String getName() public Member getParent() } ====================================================================== member 1: getId() = 1 getName() = "John" getParent() = null member 2: getId() = 10 getName() = "Joe getParent() = <member1> ====================================================================== <member id="1"> <name>John</name> </member> <member id="2"> <name>Joe</name> <parent idref="1" /> </member> Any idea how I could do this? Best regards, - Christian > -----Original Message----- > From: Christian Aust [mailto:[EMAIL PROTECTED] > Sent: Friday, January 07, 2005 11:00 AM > To: [email protected] > Subject: [betwixt] How can I make betwixt accept any attribute "id" as > an element id? > > > Hi, > > I'd like to use betwixt to serialize data beans to xml. Those beans > represent database structures mapped with hibernate, so all of the > first-rank entities sport some property id, just like this: > > public long getId() > > Those classes implement equals() as such it considers two elements > equal > if their id matches. Unfortunately, while serializing large object > trees > betwixt doesn't see this and assinges new id values to those instances. > > <object id="100"> > <id>17</id> > </object> > > What do I have to do in order to make betwixt recognize those id > attributes as element ids? Thanks a lot and best regards, > > - Christian Aust > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Christian Aust mailto:[EMAIL PROTECTED] icq: 84500990 - Yahoo!: datenimperator - MSN: datenimperator PGP: A94E 0181 664D 27E3 F05A A751 6A7E 90D1 A0A3 DEC7 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
