Thanks for all the replies. I fixed it at the hibernate end, but marking inverse="false" on the one-to-many end...
 
- Ravinder.

 
On 7/21/06, Ilya Sterin <[EMAIL PROTECTED]> wrote:
Actually here is an excerpt from a paper on OXM by HP...

############5) Serialising a Graph of Objects: XML is a hierarchical
data structure, and can only describe trees or lists of data.
Java classes almost invariably refer to other objects, often
creating cyclic graphs of references. If such a cyclic graph
is to be mapped into XML, the mapping infrastructure must
recognise the cycle (a naive implementation would enter a
non-terminating loop). Once the cycle is recognised, it must
be addressed. The options appear to be:
1) Signal an error.
2) Insert cross references into the XML message, for
processing by the mapper at the destination.
3) Break the graph by duplicating content in the XML.
The only one of these solutions which seamlessly mar-
shals cyclic graphs of objects is the second: inserting cross
references into the XML. The SOAP solution for this is
described in section 5 of the specification [10]. This linking
mechanism is only supported in RPC/encoded messages; the
document/literal message format does not allow it.
JAX-RPC was originally based on RPC/encoded messages,
but the alternate representation, document/literal, is now
broadly agreed to be more flexible and generally superior.
There is no way to marshal a cyclic graph into a docu-
ment/literal message without custom code. Any technology
that attempts to map XML to a cyclic object graph will suffer
from the same problem.
######################
 

Ilya

On 7/21/06, Ilya Sterin < [EMAIL PROTECTED]> wrote:
I guess including another structure maps-as="Person"
in your address mapping would create an infinite loop?

Try that and let me know what happens, but it might not work.

If I get a chance tonight, I'll see if I can get more creative.
 

Ilya


On 7/21/06, Ravinder Battu < [EMAIL PROTECTED]> wrote:
Thanks for the reply IIya.
 
Here is the binding file..
 

<?xml version="1.0" encoding="UTF-8"?>

<binding>
< mapping class="Person" name="person ">
    
<value name="name" field="name"/>
    
<collection field ="addresses" get-method="getAddresses" set-method ="setAddresses" type="java.util.HashSet">
             
<structure map-as="Address"/>
     
</collection>
</mapping>
<
mapping class="Address" name ="address">
     <value name="type" field ="type" style="attribute"/>
     <value name="street" field ="street"/>
</mapping>
</
binding>
 
I don't know if I have to put something in the Address mapping to say that it has an association to Person.

I greatly appreciate your help!!
 
Thanks
 
On 7/21/06, Ilya Sterin < [EMAIL PROTECTED]> wrote:
Can you send us your JiBX binding file as well?  I think you can just define two mappings and reference the address mapping within your person mapping.  Your address mapping will then contain a structure for the person.

Either way, send us your mapping file and we'll take a look.

Ilya Sterin

On 7/21/06, Ravinder Battu < [EMAIL PROTECTED] > wrote:
I am new to JiBX. I am trying to read an XML document, marshall it to Java Objects (POJO's) and persist them using hibernate.
 
Here's an example of what I am trying to do: A Person can have many addresses
 
<person>
         <name>Joe</name>
         <address type="home">
               <street>Home street</street>
         </address>
         <address type="business">
                <street>Office street</street>
         </address>
</person>
 
I have POJO's for Person and Address created (which are hibernate friendly)
public class Person {
         private string name;
         Set addresses;
         // No arg constructor
         // Getters and Setters etc.
}
 
public class Address {
        private string type;
        private string street;
        private Person addressFor;
        // No arg constructor
        // Getters and setters
}
 
When I use JiBX and marshall my XML document and try to persist it, I get an NullPointerException because the addressFor field in Address object is not getting set.
 
Any ideas on how I can do this?
 
I appreciate your help!!
 
Thanks
         
        

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users



 

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users





-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to