Discriminator NPE when case value is null

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

Discriminator NPE when case value is null

Anna

Hi !

I'm using mybatis 3.2.7

When discriminator is used with <case> tag using the value of a database column, an NPE is generated from DefaultResultSetHandler when the value of the discriminator column is null. This is because the query is created using outer join on the table having the discriminator column and so null can come as the value of the discriminator column, and no case is defined for null value . 

 Can someone please help me on how to avoid this. 

I have provided resultType along with the <case> tag to avoid the NPE when no resultType is provided


--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Discriminator NPE when case value is null

Guy Rouillier-2
Update your SQL to map the null column value to some non-null value that you can test for (or ignore).  So if your expected non-null values are 1, 2, 3, 4, then set the null case to -100.

--
Guy Rouillier

------ Original Message ------
From: "AMathew" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 8/4/2017 2:44:38 AM
Subject: Discriminator NPE when case value is null

Hi !

I'm using mybatis 3.2.7

When discriminator is used with <case> tag using the value of a database column, an NPE is generated from DefaultResultSetHandler when the value of the discriminator column is null. This is because the query is created using outer join on the table having the discriminator column and so null can come as the value of the discriminator column, and no case is defined for null value . 

 Can someone please help me on how to avoid this. 

I have provided resultType along with the <case> tag to avoid the NPE when no resultType is provided


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

Virus-free. www.avast.com

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Discriminator NPE when case value is null

Anna
But wont this create an unwanted return object? Is there some way to avoid that?

On Friday, August 4, 2017 at 12:32:25 PM UTC+5:30, Guy Rouillier wrote:
Update your SQL to map the null column value to some non-null value that you can test for (or ignore).  So if your expected non-null values are 1, 2, 3, 4, then set the null case to -100.

--
Guy Rouillier

------ Original Message ------
From: "AMathew" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RgHCLR2tBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">anna....@...>
To: "mybatis-user" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RgHCLR2tBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...>
Sent: 8/4/2017 2:44:38 AM
Subject: Discriminator NPE when case value is null

Hi !

I'm using mybatis 3.2.7

When discriminator is used with <case> tag using the value of a database column, an NPE is generated from DefaultResultSetHandler when the value of the discriminator column is null. This is because the query is created using outer join on the table having the discriminator column and so null can come as the value of the discriminator column, and no case is defined for null value . 

 Can someone please help me on how to avoid this. 

I have provided resultType along with the <case> tag to avoid the NPE when no resultType is provided


--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="RgHCLR2tBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

<a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=emailclient&amp;utm_term=icon" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dicon\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdgn6XHtGdGX0_ztl7zsznn9rycA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dicon\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdgn6XHtGdGX0_ztl7zsznn9rycA&#39;;return true;"> Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=emailclient&amp;utm_term=link" style="color:#4453ea" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dlink\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBTW1oVO7X9WxlATGseHnM8Gn-HQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dlink\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBTW1oVO7X9WxlATGseHnM8Gn-HQ&#39;;return true;">www.avast.com
<a href="#em666218bb-d76e-42ac-bf4a-013a52517240@asus_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1" rel="nofollow" onmousedown="this.href=&#39;#em666218bb-d76e-42ac-bf4a-013a52517240@asus_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2&#39;;return true;" onclick="this.href=&#39;#em666218bb-d76e-42ac-bf4a-013a52517240@asus_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2&#39;;return true;">

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