Sachin Mittal wrote:
> Hi,
> Here I am using primitive type int. I cannot do anything like you have
> mentioned with int.
> I can change that to java.lang.Integer but again this class does not have
> any no argument constructor or factory method that returns new instance of
> Integer.
> Infact I had tried replacing int with java.lang.Integer and this still did
> not work.
> 
> So question is how can we use primitive types in jibx mappings.
> 

        JiBX does not handle primitives well, it assumes everything is a going 
into a class.

        I'm guessing (based upon your mapping fragment) your XML is:

<calendar_campaign_identifier>12345</calendar_campaign_identifier>

        I would write the mapping for this as:
<value style="element" get-method="getCalendarCampaignId" 
set-method="setCalendarCampaignId" name="calendar_campaign_id">

        Get rid of the <structure ...> and <type ...> tags. The conversion from 
string to integer is done in the get/setCalendarCampaignID() methods.

> Thanks
> Sachin
> 
> 
> 
> Thomas Jones-Low wrote:
>> Sachin Mittal wrote:
>>> Hi,
>>> I am getting this above error.
>>> My mapping is as followed:
>>> <structure get-method="getCalendarCampaignId"
>>> set-method="setCalendarCampaignId" name="calendar_campaign_identifier">
>>>                     <value style="element" name="calendar_campaign_id"
>>> type="int"/>
>>> </structure>
>>>
>>> Also as per docs I have added a serializer and deserializer methods for
>>> type
>>> int:
>>>     <format type="int" serializer="java.lang.String.valueOf"
>>> deserializer="java.lang.Integer.parseInt"/>
>>>
>>> So even after all this its not working and I am getting this error when
>>> binding is compiled:
>>> Error: Need no-argument constructor or factory method for class int;
>>>
>>      As the error message says, the class you are putting the value into 
>> needs to be created in some way. JiBX requires either you create a 
>> constructor with no argument  (e.g. MyClass() {} )  or create a method 
>> which returns a (potentially new copy) of your class (e.g. static 
>> MyClass getNewMyClass() {...}).
>>
>>
> 
> 
> -----
> http://www.assembla.com/wiki/show/sachin_mittal about me: 


-- 
        Thomas Jones-Low            Softstart Services Inc.
        tjone...@softstart.com      JobScheduler for Oracle
        Ph: 802-398-1012            http://www.softstart.com

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to