ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Bradley <debrad...@gmail.com>
Subject Re: Group By for multiple column primary keys
Date Fri, 14 Oct 2005 20:12:10 GMT
Here's a working example of a compound key from a project of mine:

<sqlMap namespace="Account">
	<resultMap id="account-result" class="account">
		<result property="id.number" column="id" />
		<result property="id.version" column="version" />
...
	<select id="getAccountByVersionId" resultMap="account-result"
		parameterClass="versionId">
		<![CDATA[
         select * from accounts
         where id=#number# and version=#version#
         and deleted=0
         ]]>
	</select>

<sqlMap namespace="Organization">
	<resultMap id="organization-result" class="organization">
		<result property="id.number" column="id" />
		<result property="id.version" column="version" />
		<result property="accounts" column="{id=id,version=version}"
			select="getAccountsForOrganizationId" />
...

On 10/14/05, Alan Chandler <alan@chandlerfamily.org.uk> wrote:
> I have a table in which I have just add to change it from one to two columns
> making up the primary key. (before it was column "sid", now I also need
> "m_no")
>
> This is how I used to do it
>
>         <resultMap id="family-list" class="family"
>                 groupBy="marriage.spouse.id" >
>                 <result property="marriage.spouse.id" column="sid" />
>                 <result property="marriage.m_no" column="m_no" />
> ...
>
> I think the manual implies this - is it correct?
>
> <resultMap id="family-list" class="family"
>         groupBy="a_key" >
>         <result property=a_key column="{marriage.spouse.id = sid, marriage.m_no
> =m_no}" />
>
> ... (ignoring mail wordwrap issues)
>
>
> --
> Alan Chandler
> http://www.chandlerfamily.org.uk
> Open Source. It's the difference between trust and antitrust.
>

Mime
View raw message