You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Alex O <de...@alexoren.com> on 2008/08/21 18:52:10 UTC

Same queries, different tables

Hello,

Please suggest the best way to customize a set of queries to use different
tables (but same columns).

For example, let's say that I have a humongous amount of customers and the
DBA decided to split into tables by continent.  Let us also assume that
there will be 7 distinct subcomponents and each one only deals with a
particular continent.

So, instead of the current query:
  select name, address, phone from USERS where some_criterion
one component may query:
  select name, address, phone from AFRICA_USERS where some_criterion
while another will query:
  select name, address, phone from EUROPE_USERS where some_criterion

The components will be completely identical except for the tables they will
use.
The number of different queries can be large.

I do not really want to change the code to have the table names passed
explicitly to the ibatis queries.
In particular, some queries have no parameters (or accept a single primitive
parameter) and changing the code to explicitly carry the table names around.

So is it possible to achieve this changing only the XML configuration files?

Thank you,
Alex.

-- 
View this message in context: http://www.nabble.com/Same-queries%2C-different-tables-tp19092704p19092704.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: Same queries, different tables

Posted by Sundar Sankar <fa...@gmail.com>.
I thought you can pass table names dynamically using a $table_name. My best
bet would be to create the table name at your dao layer and pass it as a
param to the query.



On Thu, Aug 21, 2008 at 11:31 AM, Nicholoz Koka Kiknadze <kiknadze@gmail.com
> wrote:

> To be honest in the first place I'd ask DBA to use partitioning if your db
> engine supports that, and if not, to create union USERS query to run my
> queries against.
>

Re: Same queries, different tables

Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
To be honest in the first place I'd ask DBA to use partitioning if your db
engine supports that, and if not, to create union USERS query to run my
queries against.