ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "M.H. Avegaart (JIRA)" <ibatis-...@incubator.apache.org>
Subject [jira] Created: (IBATIS-412) Allow parameters as values in composite keys
Date Tue, 03 Apr 2007 09:33:32 GMT
Allow parameters as values in composite keys

                 Key: IBATIS-412
                 URL: https://issues.apache.org/jira/browse/IBATIS-412
             Project: iBatis for Java
          Issue Type: New Feature
          Components: SQL Maps
    Affects Versions: 2.3.0
            Reporter: M.H. Avegaart

Assume a master table TABLE1 with fields KEY1 and FIELD1 (primary key KEY1) and a detail table
TABLE2 with fields KEY, KEY2 and FIELD2 (composite primary key KEY1, KEY2). TABLE1 is mapped
on a class Table1, TABLE2 is mapped on a class Table2 and Table1 has a list property that
contains a List of Table2 objects.

I would like to query for all Table1 objects with a specific field1 value together with the
corresponding Table2 objects with a specific key2 value, but this is currently not possible
without joining TABLE1 and TABLE2 in a single query (which I can't use because I really need
to use lazy loading !).

Would it be possible to change SQL Maps to allow the following syntax:

<parameterMap id="params1" class="test.MyParams1">
	<parameter property="field1" />
	<parameter property="key2" />

<resultMap id="result1" class="test.Table1">
	<result property="key1" column="KEY1" />
	<result property="field1" column="FIELD1" />
	<result property="list" column="{key1=KEY1,key2=#key2#}" select="select2" />

<select id="select1" parameterMap="params1" resultMap="result1">
	from TABLE1
		FIELD1 = ?]]>

<parameterMap id="params2" class="test.MyParams2">
	<parameter property="key1" />
	<parameter property="key2" />

<resultMap id="result2" class="test.Table2">
	<result property="key1" column="KEY1" />
	<result property="key2" column="KEY2" />
	<result property="field2" column="FIELD2" />

<select id="select2" parameterMap="params2" resultClass="test.MyResult2">
	from TABLE2
		KEY1 = ? and
		KEY2 = ?]]>

Here, the column attribute for the list field specifies the KEY1 column and the key2 parameter
as parameters for the select2 query.

ps. I tried to add the field2 parameter as a field to the select statement of the select1
query, but most databases (DB2 in my case) don't allow this.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message