You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Kai Grabfelder (JIRA)" <ib...@incubator.apache.org> on 2009/05/01 13:59:30 UTC

[jira] Commented: (IBATIS-483) Empty/Null resultset from subselect causes NPE

    [ https://issues.apache.org/jira/browse/IBATIS-483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704967#action_12704967 ] 

Kai Grabfelder commented on IBATIS-483:
---------------------------------------

could you please post a stacktrace so that we can see where the NPE occurs? A testcase would also be really great

> Empty/Null resultset from subselect causes NPE
> ----------------------------------------------
>
>                 Key: IBATIS-483
>                 URL: https://issues.apache.org/jira/browse/IBATIS-483
>             Project: iBatis for Java
>          Issue Type: Bug
>          Components: SQL Maps
>    Affects Versions: 2.3.0
>         Environment: Ubuntu Linux, Tomcat 5/6, MySQL
>            Reporter: John Crawford
>             Fix For: 2.1.7
>
>
> When doing a subselect (using maps), I get a NPE when the result of the subselect is null/empty.  I believe that this occurs in every version since 2.1.7, but unfortunately, I have to stick with 2.1.7 because of this issue.  (And, of course, the maven repos only have 2.3, so I have to do an annoying workaround for it)
> Example Code:  (Issue is with the lineItems mapping from the first resultMap)
> 	<resultMap class="com.acp.beans.OrderCart" id="cartBean">
> 		<result property="id" column="cart_id"/>
> 		<result property="orderId" column="order_id" nullValue="-1"/>
> 		<result property="lineItems" column="cart_id" select="getLineItems"/>
> 		<result property="user" column="user_id" select="getUserById"/>
> 		<result property="created" column="create_dt"/>
> 	</resultMap>
> 	<resultMap class="com.acp.beans.OrderItems" id="lineItemsBean">
> 		<result property="id" column="order_item_id" />
> 		<result property="cartId" column="cart_id"/>
> 		<result property="quantity" column="quantity"/>
> 		<result property="orderPictureBean" column="picture_id" select="getOrderPictures"/>
> 		<result property="pictureSize.id" column="picture_size_id"/>
> 		<result property="pictureSize.title" column="picture_size_title"/>
> 		<result property="pictureSize.cost" column="picture_size_cost"/>
> 		<result property="pictureSize.pictureUrl" column="picture_size_link_url_th"/>
> 		<result property="pictureType.id" column="picture_type_id"/>
> 		<result property="pictureType.title" column="picture_type_title"/>
> 		<result property="pictureType.cost" column="picture_type_cost"/>
> 	</resultMap>
> 	<select id="getLineItems" parameterClass="java.lang.Integer" resultMap="lineItemsBean">
> 		SELECT
> 			OI.cart_id,
> 			OI.order_item_id,
> 			OI.quantity,
> 			OI.picture_id,
> 			OI.picture_size as picture_size_id,
> 			PS.title AS picture_size_title,
> 			PS.cost AS picture_size_cost,
> 			PS.link_url_th AS picture_size_link_url_th,
> 			OI.picture_type as picture_type_id,
> 			PT.title AS picture_type_title,
> 			PT.cost AS picture_type_cost
> 		FROM
> 			tb_OrderItem OI
> 			JOIN tb_PictureSize PS on PS.picture_size_id = OI.picture_size
> 			JOIN tb_PictureType PT on PT.picture_type_id = OI.picture_type
> 		WHERE
> 			OI.cart_id = #cart_id#	
> 	</select>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.