Is there a way to include the table name in the column resultmap definitions generated by ibator?
This would be very useful when having joins with column name collisions: An example: - TABLE "PRODUCT" having ID and NAME columns - TABLE "CATEGORY" having ID and NAME columns Ibator generated resultmaps currently look like: <resultMap class="test.Product" id="productResult"> <result column="ID" jdbcType="INTEGER" property="id" /> <result column="NAME" jdbcType="VARCHAR" property="name" /> </resultMap> <resultMap class="test.Category" id="categoryResult"> <result column="ID" jdbcType="INTEGER" property="id" /> <result column="NAME" jdbcType="VARCHAR" property="name" /> </resultMap> Now I want to extend the generated sqlmap to add the category to every product as follows: <resultMap class="test.Product" extends="productResult" id="productWithCategoryResult"> <result property="category" resultMap="CATEGORY.categoryResult " /> </resultMap> The select would look like: <select id="selectProductsWithCategory" resultMap="productWithCategoryResult"> select PRODUCT.*, CATEGORY.* where CATEGORY.ID = PRODUCT.CATEGORY_ID </select> Without having the tablenames in the resultmap, ibatis does not know which ID or NAME column to map to which object. So I end up having the value of PRODUCT.ID and PRODUCT.NAME in my created Category instance. Serveral posts suggest to not use wildcards in the select statement and to define column aliases to avoid column name collisions. But this is very tedious and you have to write your own join resultMaps to match with the column defined aliases aswell. A working solution is to change the ibator generated resultmaps to include the table name in the column attribute: <resultMap class="test.Product" id="productResult"> <result column="PRODUCT.ID" jdbcType="INTEGER" property="id" /> <result column="PRODUCT.NAME" jdbcType="VARCHAR" property="name" /> </resultMap> <resultMap class="test.Category" id="categoryResult"> <result column="CATEGORY.ID" jdbcType="INTEGER" property="id" /> <result column="CATEGORY.NAME" jdbcType="VARCHAR" property="name" /> </resultMap> Works like a charm, but every time I re-generate the sqlmaps my changes are thrown away and I have to make them again by hand. I searched the mailing list and found out that you can define an "alias" for each table, but this isn't helping in my case either. If it can't already be done somehow, my suggestion would be to include an "includeTablenameInColumns" switch in ibator. Thanks for your help, B. Behler