ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ahmed, Arshad" <aah...@cavtel.com>
Subject RE: iBATIS: NullPointerException when returning value from a stored procedure in MSSQL
Date Fri, 22 Feb 2008 16:47:29 GMT







I upgraded to iBATIS 2.1.7 and the nullpointer exception is gone.
However the return value is still null. The java code that takes the
return value is:
Object obj = sqlMap.queryForObject("sp_insert_ebonding_vendororder_b",
venOrder);

The obj returned is null. The following is my stored procedure in MS SQL
if that helps. This project I'm doing in migrating our database from
Informix to MS SQL. This code was running fine in Informix but fails in
MS SQL. Thanks for your help on this.


CREATE        PROCEDURE sp_insert_ebonding_vendororder_b( 
@iWorkQueueId int, 
@iOrderItemId int, 
@iVendorId int, 
@iVendorOrderTypeId int, 
@iVendorStatusId int, 
@iVendorTicket varchar(20), 
@iAddedBy char(8), 
@iContactName varchar(30), 
@iContactCid char(12), 
@iWorkNotes varchar(255), 
@iVendorRespId int, 
@iUpdatedBy char(8), 
@iResponseText varchar(255), 
@iVendorLineTypeId int, 
@iActionCode varchar(20), 
@iIncidentId integer, 
@iVendorMeet char(1), 
@iCallingSystemId integer, 
@iDBSystemId integer, 
@iCommitDate datetime
) 

------------------------------------------------------------------------
----------------------------- 
-- Program Name: EBondingWebService (Repair System) 
-- 
-- Description: This stored procedure will insert a vendor order record
into vendor_orders table, 
-- on the same time if macdorderitem_id provide, it will insert into
vendor_macdmap as 
-- well. 
-- Incoming Parameters: iWorkQueueId, iOrderItemId, iVendorId, 
-- iVendorOrderTypeId, iVendorStatusId, iVendorTicket, 
-- iAddedBy, iContactName, iContactCid, iWorkNotes, 
-- iVendorRespId, iUpdatedBy, iResponseText, 
-- iVendorLineTypeId, iVendorMeet, iCallingSystemId, iDBSystemId,
iCommitDate 
-- 
-- Outgoing Parameters: mVendorOrderID 
-- 
-- Table(s) Used: vendor_orders, vendor_macdmap 
-- 
-- Table(s) Updated: 
-- 
-- Referenced SPs: None 
-- 
-- Remarks: 
-- execution time in tstprovisok :0.55 sec 
---- execute procedure sp_insert_ebta_vendororder_b( 9103604, 9780063,
14, 23, 150,NULL, user, 
-- user, '586-758-6588',NULL, NULL, user,NULL,NULL, 'RP',3987392, 'N',
14, current); 
-- Modifications 
-- Date By Remarks 
-- 05/02/2007 J Ritter TicketNo=31028. Removed committed read call. 
-- 05/07/2007 J Ritter TicketNo=31061. Modified way in which to
determine Vendor PON. 
-- 05/09/2007 J Ritter TicketNo=31061. Changed Count(*) to
Count(order_item_id) in Vendor PON statement. 
-- 06/04/2007 J Ritter TicketNo=31210. Need to revert back to old PON
versioning for Vendor Order PONs. 
-- 06/05/2007 J Ritter TicketNo=31210. Additional change for how Vendor
Order PONs are determined. 
-- 07/19/2007 J Ritter TicketNo=31210. New code (and proc) for
WorkQ/Servigistics Vendor Order Creation. 
-- 07/31/2007 J Ritter TicketNo=31462. New code for WorkQ/Servigistics
Vendor Order Creation (changes to past ticket). 
-- 09/19/2007 J Ritter TicketNo=31671. New code for CRS Vendor Order
Creation (changes to past ticket). 
-- 10/09/2007 J Ritter TicketNo=31671. New code for CRS Vendor Order
Creation (changes to vendor_order_mapping update - mVendorOrderID). 


------------------------------------------------------------------------
----------------------------- 
AS
BEGIN
--SET NOCOUNT ON;
DECLARE @vendorPon VARCHAR(20); 
DECLARE @mWorkStatusID INTEGER; 
DECLARE @mNumOfVendorPon INTEGER; 
DECLARE @mWorkQueueID INTEGER;
DECLARE @mVendorOrderID INTEGER

SELECT @mNumOfVendorPon=COUNT(vendor_order_id) 
FROM vendor_order_mapping 
WHERE order_item_id = @iWorkQueueId;

SET @mNumOfVendorPon = @mNumOfVendorPon + 1; 
-- CRS PON is based on their Ticket Id and Task Id combined.
SET @vendorPon = @iActionCode + '-' + CAST(@iWorkQueueId AS VARCHAR(30))
+ '-' + CAST(@iOrderItemId AS VARCHAR(30)) + '-' + CAST(@mNumOfVendorPon
AS VARCHAR(30));

INSERT INTO vendor_orders( 
vendor_id, 
vendor_order_type_id, 
vendor_status_id, 
vendor_pon, 
vendor_ticket, 
added_date, 
added_by, 
contact_name, 
contact_cid, 
work_notes, 
vendor_response_id, 
socdate, 
updated_by, 
updated_date, 
response_text, 
vendor_line_type_id, 
commit_date, 
vendor_meet_flag, 
calling_db_system_id, 
updated_by_app) 
VALUES( 
@iVendorId, 
@iVendorOrderTypeId, 
@iVendorStatusId, 
@vendorPon, 
@iVendorTicket, 
GETDATE(),
@iAddedBy, 
@iContactName, 
@iContactCid, 
@iWorkNotes, 
@iVendorRespId, 
NULL, 
@iUpdatedBy, 
GETDATE(), 
@iResponseText, 
@iVendorLineTypeId, 
@iCommitDate, 
@iVendorMeet, 

@iCallingSystemId, 
'ebonding'); 

SET @mVendorOrderID = SCOPE_IDENTITY(); 

-- Add a row in vendor_order_mapping table: 
INSERT INTO vendor_order_mapping(vendor_order_id, order_item_id) 
	VALUES(@mVendorOrderID, @iWorkQueueId); 

RETURN @mVendorOrderID; 
END








GO

-----Original Message-----
From: Larry Meadors [mailto:larry.meadors@gmail.com] 
Sent: Friday, February 22, 2008 11:18 AM
To: user-java@ibatis.apache.org
Subject: Re: iBATIS: NullPointerException when returning value from a
stored procedure in MSSQL

I only see IN parameters.

Larry


On Fri, Feb 22, 2008 at 8:46 AM, Ahmed, Arshad <aahmed@cavtel.com>
wrote:
>
>
>
>
> Hi,
>  I'm using iBATIS as a persistent mechanism to write data to MSSQL.
there is
> a stored procedure that i'm executing and it returns an integer value,
the
> procedure executes fine but when i try to collect the result back, i
get the
> following error:
>
>  com.ibatis.common.jdbc.exception.NestedSQLException:
>  --- The error occurred in VendorOrder.xml.
>  --- The error occurred while applying a parameter map.
>  --- Check the VendorOrder.paramVendorOrder.
>  --- Check the results (failed to retrieve results).
>  --- Cause: java.lang.NullPointerException
>  Caused by: java.lang.NullPointerException
>        at
>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
WithCallback(GeneralStatement.java:188)
>        at
>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
ForObject(GeneralStatement.java:104)
>        at
>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlM
apExecutorDelegate.java:561)
>        at
>
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlM
apExecutorDelegate.java:536)
>        at
>
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSes
sionImpl.java:93)
>        at
>
com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClie
ntImpl.java:70)
>        at
>
com.talk.provisioning.ebtacomservice.server.persistence.ibatis.VendorOrd
erDAO.insert(VendorOrderDAO.java:91)
>        at
>
com.talk.provisioning.ebtacomservice.server.EBondingHelper.insertVendorO
rder(EBondingHelper.java:451)
>        at
>
com.talk.provisioning.ebtacomservice.server.EBondingHelper.persistCreate
TicketPreBinding(EBondingHelper.java:703)
>        at
>
com.talk.provisioning.ebtacomservice.server.EBondingWebService.CreateTic
ket(EBondingWebService.java:158)
>        at
> com.talk.provisioning.ebtacomservice.server.Test.main(Test.java:15)
>  Caused by: java.lang.NullPointerException
>        at
>
com.ibatis.sqlmap.engine.execution.SqlExecutor.handleResults(SqlExecutor
.java:355)
>        at
>
com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQueryProcedure(Sql
Executor.java:291)
>        at
>
com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement.sqlExecute
Query(ProcedureStatement.java:34)
>        at
>
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQuery
WithCallback(GeneralStatement.java:173)
>        ... 10 more
>
>
>  the following is an extract from my SQLConfig map file
>
>
>    <parameterMap id="paramVendorOrder" class="vendor_order_class">
>      <parameter property="workQueueIDAsLong" jdbcType="INT"
> javaType="java.lang.Long" mode="IN" />
>      <parameter property="orderItemIDAsLong" jdbcType="INT"
> javaType="java.lang.Long" mode="IN" />
>      <parameter property="vendorIDAsLong" jdbcType="INT"
> javaType="java.lang.Long" mode="IN" />
>      <parameter property="vendorOrderTypeIDAsLong" jdbcType="INT"
> javaType="java.lang.Long" mode="IN" />
>      <parameter property="vendorStatusIDAsLong" jdbcType="INT"
> javaType="java.lang.Long" mode="IN" />
>      <parameter property="vendorTicket" jdbcType="VARCHAR"
> javaType="java.lang.String" mode="IN" />
>      <parameter property="createdBy" jdbcType="VARCHAR"
> javaType="java.lang.String" mode="IN" />
>      <parameter property="contactName" jdbcType="VARCHAR"
> javaType="java.lang.String" nullValue="" mode="IN" />
>      <parameter property="contactPhone" jdbcType="VARCHAR"
> javaType="java.lang.String" nullValue="" mode="IN" />
>      <parameter property="updatedBy" jdbcType="VARCHAR"
> javaType="java.lang.String" mode="IN" />
>      <parameter property="actionCode" jdbcType="VARCHAR"
> javaType="java.lang.String" mode="IN" />
>      <parameter property="incidentIDAsLong" jdbcType="INT"
> javaType="java.lang.Long" mode="IN" />
>      <parameter property="vendorMeet" jdbcType="VARCHAR"
> javaType="java.lang.String" mode="IN" />
>      <parameter property="callingSystemIDAsLong" jdbcType="INT"
> javaType="java.lang.Long" mode="IN" />
>      <parameter property="DBSystemIDAsLong" jdbcType="INT"
> javaType="java.lang.Long" mode="IN" />
>      <parameter property="commitTime" jdbcType="DATETIME"
> javaType="java.util.Date" mode="IN" />
>    </parameterMap>
>
>    <procedure id="sp_insert_ebonding_vendororder_b"
> resultClass="java.lang.Long" parameterMap="paramVendorOrder">
>      {call
>
sp_insert_ebonding_vendororder_b(?,?,?,?,?,?,?,?,?,null,null,?,null,null
,?,?,?,?,?,?)}
>    </procedure>
>
>  can someone please help me?
>
>  Thanks.

Mime
View raw message