nope.


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ravinder Battu
Sent: Friday, July 21, 2006 2:36 PM
To: JiBX users
Subject: Re: [jibx-users] JIBX and Hibernate - bi-directional references

Thanks for quick reply Joshua. But I think it's not a good idea to include code in your POJO (i.e. postset method) that is too specific to JiBX..
 
Is there any other way to do this other than adding custom JiBX code to my POJO's?
 
Thanks
Ravinder

 
On 7/21/06, Davies, Joshua <[EMAIL PROTECTED]> wrote:
Try this:
 
<mapping class="Address" name="address" post-set="postset">
...
 
public class Address
{
...
  public void postset( IUnmarshallingContext ctx )
  {
    addressFor = ( Person ) ctx.getStackObject( 1 );
  }
}


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ] On Behalf Of Ravinder Battu
Sent: Friday, July 21, 2006 1:51 PM
To: JiBX users
Subject: Re: [jibx-users] JIBX and Hibernate - bi-directional references

 
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

Reply via email to