what is the resultant xml structure that you are trying to achieve,,,!!!

On Tue, Aug 26, 2008 at 8:16 AM, Sundeep Malali <[EMAIL PROTECTED]>wrote:

> Hi
>
> I have just started using JIBX and have a query.
>
> I have 2 classes which share a parent-child one-to-many relation. For
> displaying purposes, I get a list of all children (in general, not specific
> to a parent) and also the parent info for each child. Now I pass each child
> object to convert to xml. But while converting the child object, I also want
> the parent to be converted to xml.
>
> The binding info is given below :
>
> *Child object binding:*
> <mapping class="com.redbus.homedelivery.orm.OrderTb" name="orderTb">
>     <value style="element" name="order-id" field="orderId"/>
>     <structure field="customer"/> - This is the parent object
> </mapping>
>
> *Parent object binding*:
> <mapping class="com.redbus.homedelivery.orm.Customer" name="customer">
>     <value style="element" name="customer-id" field="customerId"/>
>     <collection field="orders"
> item-type="com.redbus.homedelivery.orm.OrderTb"/> - This is the child
> object.
> </mapping>
>
> While using this binding, I get a null pointer exception in the parent
> object.
>
> ----------------------------------------------------------------------------------------------------------------
> Caused by: java.lang.NullPointerException
>     at
> com.redbus.homedelivery.orm.Customer.JiBX_HomeDelivery_jibx_binding_binding_marshal_1_0(Customer.java)
>     at
> com.redbus.homedelivery.orm.JiBX_HomeDelivery_jibx_binding_bindingCustomer_access.marshal()
>     at
> com.redbus.homedelivery.orm.OrderTb.JiBX_HomeDelivery_jibx_binding_binding_marshal_1_0(OrderTb.java)
>     at
> com.redbus.homedelivery.orm.JiBX_HomeDelivery_jibx_binding_bindingOrderTb_access.marshal()
>     at com.redbus.homedelivery.orm.OrderTb.marshal(OrderTb.java)
>     at
> org.jibx.runtime.impl.MarshallingContext.marshalRoot(MarshallingContext.java:1041)
>     at
> org.jibx.runtime.impl.MarshallingContext.marshalDocument(MarshallingContext.java:1111)
>     at com.redbus.homedelivery.common.XMLUtils.getXML(XMLUtils.java:27)
>
> ----------------------------------------------------------------------------------------------------------------
>
> The code to perform the conversion is given below :
>
>     public static String getXML(Object obj) {
>         String xml = "";
>         try {
>             IBindingFactory bfact;
>             bfact = BindingDirectory.getFactory(obj.getClass());
>             // marshal root object back out to document in memory
>             IMarshallingContext mctx = bfact.createMarshallingContext();
>             mctx.setIndent(2);
>             ByteArrayOutputStream bos = new ByteArrayOutputStream();
>             mctx.marshalDocument(obj, "UTF-8", null, bos);
>             xml = new String(bos.toByteArray(),"UTF-8");
>         } catch (Exception e) {
>             throw new MarshallingException("Unable to marshal from the
> object " + obj, e);
>         }
>         return xml;
>     }
>
> I pass the child object to this method and want the parent to be also
> included in the final xml. The child object has the parent reference loaded
> properly.
>
> Any help is greatly appreciated.
>
> Regds
> Sundeep
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> jibx-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to