Hi Linus,

Thanks for your answer. Unfortunately I have tried and it doesn't seem to work for me. Here is my mapping:

               <collection name="flightLegs"
                                 field="flightLegs"
                                 usage="optional"
                                 item-type="entities.FlightLeg"
                                 add-method="addFlightLegs"
                                 iter-method="getFlightLegsIterator"
                                 test-method="hasFlightLegs">

My java POJO has of course the concerned methods. But still, I get the following error when trying to map it:

org.jibx.runtime.JiBXException: Add method addFlightLegs not found in collection type java.util.Collection at tag "collection"(line 51, col 249, in itineraryserver/output/cumul/src/conf/jibx/ItineraryRendition-binding.xml)
at org.jibx.runtime.impl.UnmarshallingContext.throwStartTagException(UnmarshallingContext.java:2725)
at org.jibx.binding.def.BindingBuilder.unmarshalStructure(BindingBuilder.java:1153)
at org.jibx.binding.def.BindingBuilder.unmarshalStructureChildren(BindingBuilder.java:837)


Which version of jibx are you using? Do you have an idea why it works for you and not for me?

Thank you very much.

Fran�ois

Linus Kamb wrote:

I use hibernate and map collections as follows:

        <collection name="Configurations" usage="optional" ordered="true"
            item-type="edu.iris.dmc.isis.StationConfiguration"
            add-method="addConfiguration"
            iter-method="getConfigurationsIterator"
            test-method="hasConfiguration" />

although, I guess my POJOs are not so PO anymo', having added the various JiBX-required methods. You could modify the hbm2java source generator code to add them, since they are pretty generic. I did some of that.

I *think* you can just leave out the collection type, since the hibernate collections support the Collection interface, which supplies an iterator() method.

Fran�ois Eric wrote:

Hello,

I am having a rather important problem with my mapping between my xml file and my java classes (pojos). Right now I am trying to bind xml files to my hibernate pojos. Here is a sample of my mapping:

<mapping name="Itinerary" class="entities.Itinerary">
<collection name="flightLegs" field="flightLegs" type="java.util.HashSet" usage="optional">
<structure name="FlightLeg" type="entities.FlightLeg" usage="optional">
...
</structure>
</collection>
</mapping>



This works great if I load an xml file and unmarshall it using jibx. My problem occurs when I populate my POJO hibernate classes by fetching the data from the db and then try to marshall them in xml documents. The reason is that hibernate instantiates net.sf.hibernate.collections.Set for collections rather than a java.util.HashSet. Therefore, JIBX will give me a compilation error because it tries to use a java.util.HashSet. And in case you are wondering, I cannot use net.sf.hibernate.collection.Set for my collections in my POJOs because a hibernate session is needed to instantiate such an object.


Is there a way to have a different "type" for marshalling and unmarshalling collections? Or is there a workaround to my problem?

Any help would be greatly appreciated,

Thank you,

Fran�ois






------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_idP47&alloc_id808&op�k _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users








------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_idP47&alloc_id808&op=click _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to