List Info

Thread: Composite Key parameter




Composite Key parameter
user name
2006-09-25 15:55:02
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.&nbsp; 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)
 &nbsp; at System.Data.SqlClient.SqlDataReader.GetOrdinal(String name)
&nbsp;  at IBatisNet.DataMapper.MappedStatements.PropertyStrategy.SelectStrategy.Set(RequestScope request, ResultMap resultMap, ResultProperty mapping, Object&; target, IDataReader reader, Object selectKeys)
 &nbsp; at IBatisNet.DataMapper.MappedStatements.ResultStrategy.ResultMapStrategy.Process(RequestScope request, IDataReader& reader, Object resultObject)
 &nbsp; at IBatisNet.DataMapper.MappedStatements.MappedStatement.RunQueryForObject[T](RequestScope request, IDalSession session, Object parameterObject, T resultObject)
   at IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObject[T](IDalSession session, Object parameterObject, T resultObject)
 &nbsp; at IBatisNet.DataMapper.MappedStatements.MappedStatement.ExecuteQueryForObject[T](IDalSession session, Object parameterObject)
&nbsp;  at IBatisNet.DataMapper.SqlMapper.QueryForObject[T](String statementName, Object parameterObject)
&nbsp;  at LS.ImageAnalysis.Execution.Persist.IBatis.ImageMapDaoImpl.Get(Int32 parentImageId, Double parentMagnification, Boolean deep) in C:SrcVSTSRatLiverToxtrunkImageAnalysisImageAnalysis.Execution.PersistIBatisImageMapDaoImpl.cs:line 27
   at LS.ImageAnalysis.Execution.Persist.Test.ImageMapDaoImplTest.IImageMapDao_GetDeepById_Test() in C:SrcVSTSRatLiverToxtrunkImageAnalysisLS.ImageAnalysis.Execution.Persist.TestImageMapDaoImplTest.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 [gmail.com">mailto:ibatis.netgmail.com]

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

To: user-csibatis.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

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



From: Luke Siler [mailto:luke.silerlsbio.com]
Sent: Monday, August 21, 2006 12:37 PM
To: user-csibatis.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"/&gt;
...
<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.&nbsp; 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.&nbsp; 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.
lukeslsbio.com
206.374.1135

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )