Hello, first of all, hello everybody since I'm new on this list even I'm using iBATIS sice a couple of months.
I'm looking for a smart trick to avoid duplicating the sql statements when using SELECT COUNT. For paginating needs, I've to execute two separate statements, the first one to count the length of the result set and the second one to fetch the data. Here's an example: <select id="myQuery" resultClass="int" parameterClass="com.MyClass"> SELECT * FROM table INNER JOIN ... ... </select> <select id="myQueryCount" resultMap="myMap" parameterClass="com.myClass"> SELECT COUNT(1) as c FROM table INNER JOIN ... //"Same" query as before. ... </select> I don't like to write twice the body of the query (which could be very long and error-prone) so I'm looking for an iBATIS feature to solve the problem (an alias, a const...) Something like the folliwing, supposing that iBATIS substitutes the $_..._$ with the body of the referred query: <select id="myQuery" resultClass="int" parameterClass="com.MyClass"> SELECT * FROM table INNER JOIN ... ... </select> <select id="myNewQueryCount" resultMap="myMap" parameterClass="com.myClass"> SELECT COUNT(1) as c FROM $_myQuery_$; ... </select> Thanks a lot Fabrizio