ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "aaron pieper (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Commented: (IBATIS-483) Empty/Null resultset from subselect causes NPE
Date Tue, 24 Feb 2009 20:13:02 GMT

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

aaron pieper commented on IBATIS-483:
-------------------------------------

I am also affected by this issue. As John has indicated, the behavior works fine in 2.1.7.597,
but is broken in 2.3.4.726.

As far as your complaint about the maven repos only having 2.3 - this isn't true. iBiblio
hosts the older iBatis jars, although they have changed location. The older jars are located
under com/ibatis/ibatis2-sqlmap and com/ibatis/ibatis2-common.

> 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.


Mime
View raw message