Thanks for reply Lukas,
  No no ,*cn *table *DOES* contain the field *"HC1_LEAF_ID", *but its value 
is null for that row.
Hence it is giving a "Null pointer exception".
It would be very tedious job do as you shown below to check NULL condition 
and its not natural way.
What if "*.eq(cd.HC1_LEAF_ID)" *is also NULL. ? What if my query has many 
such conditions with 'and' ?

So there should be any easy way / function to handle this type of 
scenarios. Otherwise developer life would be hell.
Hope you consider this in a positive way.

Thank you.
~Shyam

On Tuesday, February 18, 2014 2:59:22 PM UTC+5:30, Lukas Eder wrote:
>
> Hi Shyam,
>
> I understand, so your *cn *table doesn't contain the field *"HC1_LEAF_ID"*. 
> From how I understand your requirement, you shouldn't join the *cd *table 
> at all, in that case. This is a regular "dynamic SQL" problem, which can be 
> resolved like this:
>
> Table<?> t = cn.join(hp).on(hp.PLANE_ID.eq(cn.field("PLANE_ID")));
>
>
> // Join the cd table only if necessary / possible
>
> *if (cn.field("HC1_LEAF_ID") != null) {*
>
> *    t = t.join(cd).on(cn.field("HC1_LEAF_ID").eq(cd.HC1_LEAF_ID));*
>
> *}*
>
> Result a = ctx.select(cn.field("ID"))
>               .from(t)
>
>               .fetch();
>
>
> Does this answer your question?
>
> 2014-02-18 8:59 GMT+01:00 Sha <[email protected] <javascript:>>:
>
>> Sorry for confusion Lukas,
>> Let me give more details.
>>
>> I have a scenarios here
>>
>> Result a =  ctx.select(cn.field("ID")).from(cn)
>>   .join(hp)
>>   .on( hp.PLANE_ID.eq(cn.field("PLANE_ID")) )
>>   .join(cd)
>>   .on( *(cn.field("HC1_LEAF_ID")).eq((cd.HC1_LEAF_ID).nullif(0))*)
>>   .fetch();
>>
>> In the above , there is a condition .on( 
>> *(cn.field("HC1_LEAF_ID")).eq((cd.HC1_LEAF_ID).nullif(0))*).
>> In which currently *cn.field("HC1_LEAF_ID") = null. *So i am not able to 
>> compare it if it is equal to *cd.HC1_LEAF_ID.*
>> Is there any easy way/build-in-method to check , if the  
>> *cn.field("HC1_LEAF_ID") 
>> not equal null* then only check if it is equal to *cd.HC1_LEAF_ID ? *In 
>> one statement.
>>
>> Thank you.
>> ~Shyam
>>
>>
>>
>>
>> On Monday, February 3, 2014 8:09:29 PM UTC+5:30, Lukas Eder wrote:
>>
>>> Hi Shyam,
>>>
>>> In general, jOOQ maps Java null to SQL NULL/UNKNOWN just like JDBC does 
>>> as well. I wasn't aware of SQL Server providing a way to distinguish NULL 
>>> from "EMPTY". Could you provide an example where you think that jOOQ should 
>>> change its behaviour?
>>>
>>> Cheers
>>> Lukas
>>>
>>>
>>> 2014-02-03 Sha <[email protected]>:
>>>
>>>> Hi Lukas,
>>>>   When I try to fetch records of any table, when there is no value for 
>>>> a field JOOQ select statement fetching it as null.
>>>> In many databases , especially SQLServer no value is treated as empty 
>>>> value. 
>>>>
>>>> But by JOOQ why it is null , which in turn showing NullPointerException.
>>>> And how to evaluate it to empty value ?
>>>>
>>>> Regards,
>>>> ~Shyam
>>>>
>>>>  -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "jOOQ User Group" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>>
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to