How to find numeric type

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to find numeric type

Rong Nguyen
This post was updated on .
Hi,

I have tried to search with numeric type but i encounter java.lang.ClassCastException.

Scenario:
1. Quantity field in InvoiceItem entity has numeric type.
2. Query command:
mapCondition.put("quantity", "123");
delegator.find("InvoiceItem", EntityCondition.makeCondition(mapCondition), null, null, null, null);
3. I found flow of code after debugging:

sqlP.setValue(handler, handler.getJavaClass().cast(fieldValue));  // row 783 GenericDAO.java

public T cast(Object obj) {  // from row 2997 SqlJdbcUtil.java
        if (obj != null && !isInstance(obj))
            throw new ClassCastException();  // The code cause CCE
        return (T) obj;
    }

Is there anyone encountered this issue?
Rong Nguyen

Olbius JSC
Deliver highest business value
http://www.olbius.com/
Reply | Threaded
Open this post in threaded view
|

Re: How to find numeric type

Adrian Crum-3
mapCondition.put("quantity", BigDecimal.valueOf(123));


Adrian Crum
Sandglass Software
www.sandglass-software.com

On 10/22/2014 11:07 AM, Rong Nguyen wrote:

> Hi,
>
> I have tried to search with numeric type but i encounter
> java.lang.ClassCastException.
>
> *Scenario:*
> 1. Quantity field in InvoiceItem entity has numeric type.
> 2. Query command:
> mapCondition.put("quantity", "123");
> delegator.find("InvoiceItem", EntityCondition.makeCondition(mapCondition),
> null, null, null, null);
> 3. I found flow of code after debugging:
>
> sqlP.setValue(handler, handler.getJavaClass().cast(fieldValue));  // row 783
>
> public T cast(Object obj) {  // from row 2997
> if (obj != null && !isInstance(obj))
>    throw new ClassCastException();  // The code cause CCE
> return (T) obj;
>      }
>
> Is there anyone encountered this issue?
>
>
>
> -----
> Rong Nguyen
>
> Olbius JSC
> Deliver highest business value
> http://www.olbius.com/
> --
> View this message in context: http://ofbiz.135035.n4.nabble.com/How-to-find-numeric-type-tp4657235.html
> Sent from the OFBiz - Dev mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: How to find numeric type

Rong Nguyen
Thank Adrian,

Not good for my situation but it is the resolution.

*RONG NGUYEN (Mr)*

*OLBIUS FOUNDER**Email:* [hidden email] | *Mobile:* (+84) 902
2468 45

*OLBIUS., JSC*
*Tel:* (+84) 9 88 99 3333
*Address: *Room 2508, M3-M4 building, No 91, Nguyen Chi Thanh St., Ha Noi
City, VietNam
*Website:* http://olbius.com

On Wed, Oct 22, 2014 at 5:20 PM, Adrian Crum <
[hidden email]> wrote:

> mapCondition.put("quantity", BigDecimal.valueOf(123));
>
>
> Adrian Crum
> Sandglass Software
> www.sandglass-software.com
>
>
> On 10/22/2014 11:07 AM, Rong Nguyen wrote:
>
>> Hi,
>>
>> I have tried to search with numeric type but i encounter
>> java.lang.ClassCastException.
>>
>> *Scenario:*
>> 1. Quantity field in InvoiceItem entity has numeric type.
>> 2. Query command:
>> mapCondition.put("quantity", "123");
>> delegator.find("InvoiceItem", EntityCondition.makeCondition(
>> mapCondition),
>> null, null, null, null);
>> 3. I found flow of code after debugging:
>>
>> sqlP.setValue(handler, handler.getJavaClass().cast(fieldValue));  // row
>> 783
>>
>> public T cast(Object obj) {  // from row 2997
>>         if (obj != null && !isInstance(obj))
>>             throw new ClassCastException();  // The code cause CCE
>>         return (T) obj;
>>      }
>>
>> Is there anyone encountered this issue?
>>
>>
>>
>> -----
>> Rong Nguyen
>>
>> Olbius JSC
>> Deliver highest business value
>> http://www.olbius.com/
>> --
>> View this message in context: http://ofbiz.135035.n4.nabble.
>> com/How-to-find-numeric-type-tp4657235.html
>> Sent from the OFBiz - Dev mailing list archive at Nabble.com.
>>
>>
Rong Nguyen

Olbius JSC
Deliver highest business value
http://www.olbius.com/