ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Bradley <debrad...@gmail.com>
Subject Re: Changing a sqlMap dynamically?
Date Thu, 06 Oct 2005 16:08:50 GMT
Hi Larry -

Thanks for the reply, but I think you misunderstood the question. I
understand that I can put arbitrary SQL into a named select element
within a sqlMap file. That then gets called, by name, from

What I'm wondering is if there's either:

- a way to (essentially) call session.select("my arbitrary sql")
instead of session.select("namedQuery")
- or to created new named mappings at runtime such that
select("namedQuery") is calling a query that doesn't exist in the XML
file on disk.

My goal is, if I have 10 entities, and they all have a query that
looks like "select * from tablename" and the only that that varies is
the tablename, I'd like to be able to have my Java create that query
on the fly. I'm looking to build a general framework that handles some
of the plumbing for me instead of requiring a lot of hand work to be
done building the XML files.


On 10/6/05, Larry Meadors <lmeadors@apache.org> wrote:
> <select id="getWhatever" resultClass="java.util.HashMap" remapResults="true">
> $whateverSqlYouWant$
> </select>
> Larry
> On 10/6/05, Dan Bradley <debradley@gmail.com> wrote:
> > Using iBATIS you normally create an XML file with a sqlMap element
> > that defines SQL queries that can be referenced by name. Is it also
> > possible to create these queries dynamically, through Java, instead of
> > hard-coding them all in XML? I'm hoping to build some framework code
> > that will programatically create some common queries based on the
> > properties of an object, instead of writing a "getAll" or "getById"
> > query for every entity which varies only in the table name.
> >
> > SqlMapExecutor's query/insert/delete methods require the name of a
> > mapped statement and don't appear to allow arbitrary SQL. If iBATIS
> > supports what I'm looking for, where would you hook into the system in
> > order to create new mappings on the fly?
> >
> > Thanks.
> >

View raw message