ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luke Siler" <Lu...@lsbio.com>
Subject FW: Composite Key parameter
Date Mon, 25 Sep 2006 15:55:02 GMT
Hi,

I have a follow-up to my composite key parameter question.  I looked at
order.xml and see the following example:

<result property="FavouriteLineItem"
column="Order_ID=Order_ID,LineItem_ID=Order_FavouriteLineItem"
select="GetSpecificLineItem" />

 

I'm using the same syntax in my example but with a literal parameter
value.  Should I expect this to work?

<resultMap id="ImageMapResultDeep" class="ImageMap"
extends="ImageMapResultShallow">

<result property="TwoAndOneHalfXChildren"
column="ParentImageID=ImageID,Magnification=2.5"
select="JPPGetMappedImage" />

<result property="TwentyXChildren"
column="ParentImageID=ImageID,Magnification=20"
select="JPPGetMappedImage" />

<result property="FortyXChildren"
column="ParentImageID=ImageID,Magnification=40"
select="JPPGetMappedImage" />

</resultMap>

 

Failure details are as follows:

Test method
LS.ImageAnalysis.Execution.Persist.Test.ImageMapDaoImplTest.IImageMapDao
_GetDeepById_Test threw exception:  System.IndexOutOfRangeException:
2.5.

at System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName)
   at System.Data.SqlClient.SqlDataReader.GetOrdinal(String name)
   at
IBatisNet.DataMapper.MappedStatements.PropertyStrategy.SelectStrategy.Se
t(RequestScope request, ResultMap resultMap, ResultProperty mapping,
Object& target, IDataReader reader, Object selectKeys)
   at
IBatisNet.DataMapper.MappedStatements.ResultStrategy.ResultMapStrategy.P
rocess(RequestScope request, IDataReader& reader, Object resultObject)
   at
IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForObject[
T](RequestScope request, IDalSession session, Object parameterObject, T
resultObject)
   at
IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObj
ect[T](IDalSession session, Object parameterObject, T resultObject)
   at
IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObj
ect[T](IDalSession session, Object parameterObject)
   at IBatisNet.DataMapper.SqlMapper.QueryForObject[T](String
statementName, Object parameterObject)
   at
LS.ImageAnalysis.Execution.Persist.IBatis.ImageMapDaoImpl.Get(Int32
parentImageId, Double parentMagnification, Boolean deep) in
C:\Src\VSTS\RatLiverTox\trunk\ImageAnalysis\ImageAnalysis.Execution.Pers
ist\IBatis\ImageMapDaoImpl.cs:line 27
   at
LS.ImageAnalysis.Execution.Persist.Test.ImageMapDaoImplTest.IImageMapDao
_GetDeepById_Test() in
C:\Src\VSTS\RatLiverTox\trunk\ImageAnalysis\LS.ImageAnalysis.Execution.P
ersist.Test\ImageMapDaoImplTest.cs:line 71

 

2006/09/22 16:10:17:SSS [DEBUG] IBatisNet.DataMapper.SqlMapSession -
Open Connection "17608627" to "Microsoft SQL Server, provider V2.0.0.0
in framework .NET V2.0".
2006/09/22 16:10:17:SSS [DEBUG]
IBatisNet.DataMapper.Configuration.Statements.PreparedStatementFactory -
Statement Id: [JPPGetImageMapDeep] Prepared SQL: [dbo.JPPGetImage]
2006/09/22 16:10:17:SSS [DEBUG]
IBatisNet.DataMapper.Commands.DefaultPreparedCommand - Statement Id:
[JPPGetImageMapDeep] PreparedStatement : [dbo.JPPGetImage]
2006/09/22 16:10:17:SSS [DEBUG]
IBatisNet.DataMapper.Commands.DefaultPreparedCommand - Statement Id:
[JPPGetImageMapDeep] Parameters: [@ImageID=[ParentImageID,32]]
2006/09/22 16:10:17:SSS [DEBUG]
IBatisNet.DataMapper.Commands.DefaultPreparedCommand - Statement Id:
[JPPGetImageMapDeep] Types: [@ImageID=[Int32, System.Int32]]
2006/09/22 16:10:17:SSS [DEBUG] IBatisNet.DataMapper.SqlMapSession -
Close Connection "17608627" to "Microsoft SQL Server, provider V2.0.0.0
in framework .NET V2.0".

 

Has anyone done this or something similar successfully?

 

Thanks,

Luke

-----Original Message-----

From: Gilles Bayon [mailto:ibatis.net@gmail.com
<mailto:ibatis.net@gmail.com> ] 

Sent: Monday, September 11, 2006 10:15 AM

To: user-cs@ibatis.apache.org

Subject: Re: Composite Key parameter

It's a documentation issue that have been fixed see JIRA IBATISNET-141.

You can check order.xml mapping for exemples.

It's supported by all 'statement' tag.

--

Cheers,

Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>


________________________________

From: Luke Siler [mailto:luke.siler@lsbio.com] 
Sent: Monday, August 21, 2006 12:37 PM
To: user-cs@ibatis.apache.org
Subject: Composite Key parameter



Hi, 

I'm trying to expand a 1:M collection property based on a composite key.
The 1.3 Data Mapper Guide shows a sample of composite key parameter
mapping as follows:


Example 3.44. Mapping a composite key 
<resultMaps> 
<resultMap id="select-order-result" class="order"> 
<result property="id" column="ORD_ID"/> 
<result property="customerId" column="ORD_CST_ID"/> 
... 
<result property="payments" column="{itemId=ORD_ID, custId=ORD_CST_ID}" 
select="selectOrderPayments"/> 
</resultMap> 
<resultMaps> 
<statements> 
<statement id="selectOrderPayments" resultMap="select-payment-result"> 
select * from PAYMENT 
Working with Data Maps 
DataMapper Guide Version 1.3.0 40 
where PAY_ORD_ID = #itemId# 
and PAY_CST_ID = #custId# 
</statement> 
</statements> 
Optionally you can just specify the column names as long as they're in
the same order as the 
parameters. For example: 
{ORD_ID, ORD_CST_ID} 




However, this syntax expressed in the result map below yields the
following error message for me.  Basically, the trailing bracket "}" is
not getting parsed out properly.  If I remove the brackets then I don't
get any error but only one column of the two always seems to win.


Test method
LS.Antibody.Inventory.Persist.Test.AntibodyMakeImplTest.AntibodyMakeDao_
Get_TestMethod threw exception:  System.IndexOutOfRangeException: LSID}.


<result property="Alternatives" column="{AntibodyID, LSID}" 
select="ABPOGetAntibodyByLSID"/> 



I haven't seen any other activity on the list about this problem so
guessing I must be doing something wrong.  I've tried changing order of
columns, stored procedure parameters, played with aliasing, removing
spaces, etc.  Nothing seems to work.

Is this only supported for inline parameter mapping with <statement>
rather than <procedure>? 


Luke Siler 
Software Engineer 
LifeSpan BioSciences, Inc. 
lukes@lsbio.com 
206.374.1135 


Mime
View raw message