You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Derek Alexander <D....@lse.ac.uk> on 2008/05/28 17:06:37 UTC
Can queryForMap(...) behaviour be mimicked in the SQL Map XML
files?
Hi,
Let's say I have a class Department with a property that is of type Map that
has keys of Long and values of Employee. The key is the id of the Employee.
Sure, I can set this property in a DAO using:
department.setEmployeeMap(sqlMap.queryForMap("getEmployees",
department.getDepartmentId(), "employeeId");
However, was wondering if there is any way this can be done directly in the
SQL Map XML file so I take advantage of lazy loading.
Cheers,
D.
--
View this message in context: http://www.nabble.com/Can-queryForMap%28...%29-behaviour-be-mimicked-in-the-SQL-Map-XML-files--tp17514856p17514856.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: Can queryForMap(...) behaviour be mimicked in the SQL Map XML
files?
Posted by Derek Alexander <D....@lse.ac.uk>.
> Can queryForMap(...) behaviour be expressed in the SQL Map XML files?
I guess the answer is "no" then.
Expect it wouldn't be too much work to add this as a feature though.
In the way Complex Collection Properties (List or Collection of a business
object) can be loaded now (see, Developer Guide, page 36) one could imagine
Complex Map Properties beeing handled too. Would require some extra syntax
for the result element to specify the field to use as the Map's key and
(optionally) the Map value, perhaps:
class Department {
Map employeeMap; // (Long employeeId, Employee employee)
...
}
<resultMap id="get-department-result" class="example.Department">
<result property="employeeMap" column="DEPT_ID"
select="getEmployeesByDeptId" mapKey="employeeId"/>
...
</resultMap>
Would be a useful feature for me at least.
Cheers,
D.
--
View this message in context: http://www.nabble.com/Can-queryForMap%28...%29-behaviour-be-mimicked-in-the-SQL-Map-XML-files--tp17514856p17554512.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.