Hello, I am building an application that will need to dynamically build an SQL statement at run time, and then populate the statement's fields from a map. Sounds perfect for iBatis, right. That's what I thought, but I don't think iBatis does quite what I need. Normally iBatis can dynamically change it's SQL but you need to know things like the number, name & type of columns in advance when the SqlMap is created.
Unfortunately in my application, the SQL statement that is built at runtime is completely dynamic. The name of the columns, their data types and the number of columns will only be known at run time. So what I would like to do is dynamically instantiate an SqlMapClient from a String, which contains the SqlMap that is dynamically generated at run time. Then let iBatis do the work of converting the map's values into the correct data types and populating the SQL's field values. It would be nice if the table name could be passed as a property instead of in the map of data. This looks like it would be possible with the SqlMapClientBuilder, but I don't think that is going to work. The problem is it wants to read an SqlMapConfig, which then of course points to an SqlMap file. However, the SqlMap file obviously won't exist anywhere but as a string in ram, and it's not possible (as far as I know) to directly load an SqlMap using SqlMapClientBuilder, nor is it possible to load a single "file" (string in ram) that is a combined SqlMapConfig & SqlMap. I could probably cobble something together using the internal non-user exposed classes within iBatis, but then if those classes change from one release to the next I would have to make the appropriate changes to my code, and I would prefer to use something that is part of iBatis. So, I would like to request a feature to make dynamically building the SqlMap at runtime possible. I suppose this could be done by developing a class like SqlMapClientBuilder that accepted a String, and didn't need an SqlMapConfig, just a SqlMap XML. Alternately, a fixed API could be exposed to users to manually construct a SqlClientMap. Thoughts? Is there a better approach that works now? Did I miss something obvious? Thanks, and iBatis rocks! Rob __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new Resources site http://smallbusiness.yahoo.com/resources/