ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: Struggling to load a complex property from a secondary table (a 1:N problem)
Date Fri, 06 Jan 2006 12:19:19 GMT
Hi,

You should change the resultmap, you have to specify the columnName of
the value you would like to pass to "findPermissionByUserId":

<resultMap id="UserResultMap" class="User">
	<result property="userId" column="UserId"/>
	<result property="permissions" column="UserId"
select="findPermissionByUserId"/>
</resultMap>

Hope this helps,

Niels

-----Original Message-----
From: Paul.Smith3@barclayscapital.com
[mailto:Paul.Smith3@barclayscapital.com] 
Sent: vrijdag 6 januari 2006 13:16
To: user-java@ibatis.apache.org
Subject: Struggling to load a complex property from a secondary table (a
1:N problem)

Hi,

I am struggling with the following scenario. Basically I'm trying to get
iBatis to load a complex property (a list of int) from a secondary
table.

I have two tables, User and Permission. The pk of the User table
(UserId) is a fk in the Permission table, and there are many Permission
rows for each UserId. I am trying to get iBatis to perform the select
from the Permission table whenever a select is performed on the User
table, but I always get a 'Invalid column name' from the underlying jdbc
driver. I can't work out what query iBatis is trying to perform that is
yielding this error.

My SqlMap is setup so that the permissions property (a java.util.List of
java.lang.Integer) of the User resultMap is as follows:

<resultMap id="UserResultMap" class="User">
	<result property="userId" column="UserId"/>
	<result property="permissions" column="permissionId"
select="findPermissionByUserId"/>
</resultMap>

The "findPermissionByUserId" select is defined as:

<select id="findPermissionByUserId" parameterClass="int"
resultClass="int">
	select PermissionId as permissionId from Permissions where
UserId = #value#
</select>

The select is initaited from a "findUserById" select which is defined
as:

<select id="findUserById" parameterClass="int"
resultMap="UserResultMap">
	select * from User where UserId = #value#
</select>

Any help is greatly appreciated.

Regards,

Paul Smith



------------------------------------------------------------------------
For more information about Barclays Capital, please
visit our web site at http://www.barcap.com.


Internet communications are not secure and therefore the Barclays 
Group does not accept legal responsibility for the contents of this 
message.  Although the Barclays Group operates anti-virus programmes, 
it does not accept responsibility for any damage whatsoever that is 
caused by viruses being passed.  Any views or opinions presented are 
solely those of the author and do not necessarily represent those of the

Barclays Group.  Replies to this email may be monitored by the Barclays 
Group for operational or business reasons.

------------------------------------------------------------------------


Mime
View raw message