ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gratle...@freenet.de
Subject Lazy loading when having dynamic table names
Date Mon, 04 May 2009 14:03:38 GMT

In our DB schema (that cannot be changed) we got dynamic table names, depending
on the current company, i.e. there are tables ORDER_100, ORDER_200,... with
ORDER_100 being company 100's ORDER table, etc. 

Now everything is fine, for a single select, as I can pass the current company
as a parameter and configure query like this:

<select id="findOrders" parameterClass="org.test.OrderSearchCriteria"
 ORDER_$company$ where ORNO = $id$

But what if i want to get ORDER table's related CUSTOMER using lazy loading?

Then I will need something like:

<select id="getCustomerById" resultMap="CustomerDataResult">
  	 CUSTOMER_$company$ where CUNO =#id#

with the resultMap of orders looking like this:

<resultMap id="OrderDataResult"  class="OrderData">
    <result property="orderNumber" column="ORNO" />
    <result property="customer" column="CUNO" select="getCustomerById" />

And I can see no possibility to pass the 'company' parameter to getCustomerById
I think of generating sqlmap configuration dynamically, i.e. there would be a
get getCustomerById_100, getCustomerById_200, etc. then. But that's poor and

What would be useful is some global variable that could be set on the current
session, or something, and one could use within any statement then.

Do you have a solution to this problem?
Any comments are greatly appreciated!

Gratis: Jeden Monat 3 SMS versenden-
Mit freenetMail - Ihrer kostenlose E-Mail-Adresse

View raw message