Hi Paul 1. I'm not sure on this one, but I think you indeed have to convert the List into a Set.
2. use <result property="yourProperty" column="legacy_column" typeHandler="customTypeHandler"/> in your resultMap. In an insert/update you can use inline parameter-maps as follows: INSERT INTO table (legacy_column) VALUES (#yourProperty,handler=customTypeHandler#) Kind regards, Daan -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, January 06, 2006 14:04 To: user-java@ibatis.apache.org Subject: RE: Struggling to load a complex property from a secondary table (a 1:N problem) Thanks Niels, that works perfectly. I had completely mis-understood the use of the column attirbute when a select is present! Now, a couple of slightly more tricky questions! 1. How can I change the Collection implementation that the results get mapped into? By default it's a List but I would prefer to use a Set. I can achieve this by adding an overloaded set method that converts a List into a Set onto my business object but can I do it in the mapping process? 2. I am aware that I can register a Custom Type Handler for complex properties, but can I explicitly tell iBatis to use a specific custom type handler for a given property? The scenario is this, I have two legacy database columns that use integers to describe boolean properties. One regards null as true, the other as false (I know, I know, but it's a legacy database that can't be changed!) so I would like to use different custom type handlers for each column despite the fact that they both map from int to boolean. Thanks Paul Smith -----Original Message----- From: Niels Beekman [mailto:[EMAIL PROTECTED] Sent: 06 January 2006 12:19 To: user-java@ibatis.apache.org Subject: RE: Struggling to load a complex property from a secondary table (a 1:N problem) 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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 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. ------------------------------------------------------------------------