I'm guessing by the names that beans are not going to work for this - the field list is probably pretty fluid.
LinkedHashMap might work, try that first, but if not, then if you have the field list from the query that you are building, you could use it with a c:forEach or StringTokenizer to get the field names in order. Larry On 7/2/07, Nathan Maves <[EMAIL PROTECTED]> wrote:
Apology accepted. First off lets take a trip down the old API. from http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashMap.html "This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time." Second, you can create the order when you pull them out. But I am guessing that you are using some sort of iterator to loop through the map and print out the results, since you dont know the column names. I can only suggest that you try to create some result classes and not use maps. Maps are great for parameter maps but are generally frowned upon as a result class. As a last resort you might get away with trying to use LlinkedHashMap from java.util. Nathan On 7/2/07, Rick Accountius <[EMAIL PROTECTED] > wrote: > > Greetings, > > I'm kind of new to Ibatis, so if I'm missing the obvious, let me apologize > > right up front. > > Nonetheless, here is my problem. I am using a HashMap as the resultClass > to retrieve results from a DB2 database. My problem is the column order > (not row order) returned appears to be almost random. How do I "force" > Ibatis to return the columns in the same order as they appear (returned) > in the SQL query? > > For example, here is my query: > > SELECT A as COL_A, B as COL_B, C as COL_C from tablexxxx > > My results can be COL_B, COL_A, COL_C..........or COL_C, COL_B, > COL_A..........or , etc, etc. > > I have logged java.sql and the columns are being returned in the proper > order, but eventually they get "realigned". Can someone explain to me > why? I'd really appreciate it. I know I can use a ResultMap to have the > columns listed in the proper order, but what I'm trying to do is use the > same Ibatis select statement to "service" arbitrary SQL statements. Hope > I'm making sense. > > <select id="getReport" parameterClass="com.ibm.bean.ReportDefinition" > resultClass="java.util.HashMap" remapResults="true"> > $query$ > </select> > > Thanks, > > Regards, > > Rick Accountius > Internet: [EMAIL PROTECTED]
