Given the ResultMap for the iBatis select query, it seems mandatory that all columns (which are mapped to the properties in the ResultMap) are actually part of the SQL query.
But this is a little annoying if you want to reuse ResultMaps, especially when you have "resultmaps in resultsmaps".
Example:
<resultMap id="myResultMap" <result property="myPropName" column="myColumnName"/> <result property="someCollection" resultMap="otherResultMap"/> </resultMap> <resultMap id="otherResultMap" groupBy="..." <result property="otherPropName" column="otherColumnName"/> </resultMap>
Of course, these two result maps are defined because there is a case with a request that uses a connection to load container objects containing myPropName, and someCollection contains a collection of internal objects.
But if I want to reuse the same result map definition for another select query that only needs to load container objects (with myPropName), but does not need to load internal objects (in someCollection), then there will be an error message:
Column name "otherColumnName" was not found in this ResultSet
Is there no way to initialize someCollection with a null or empty collection if the corresponding properties (in this case otherPropName) are not present in the SQL query?
Is it really necessary to create another scorecard for this scenario?
Using iBatis (not yet myBatis) version 2.3.4 ...
source share