ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Davide Rogora" <drog...@unionefiduciaria.it>
Subject R: Pattern for multiple database
Date Thu, 23 Mar 2006 15:52:21 GMT
thank you very much for your reply.

I don't remember if  it's possible to load a SQL map xml files at runtime.
If yes, we could leave the sqlMapConfig file empty (with non sqlMap tags)
and then load the sqlMap files at runtime, looking before in the "dialect"
folder; if it's not present looking in the "common" folder.


  -----Messaggio originale-----
  Da: larry.meadors@gmail.com [mailto:larry.meadors@gmail.com]Per conto di
Larry Meadors
  Inviato: giovedì 23 marzo 2006 16.20
  A: user-java@ibatis.apache.org
  Oggetto: Re: Pattern for multiple database

  I would try a structure like this:

  Set up your SqlMapConfig.xml file to load a properties file, and in that
properties file specify the database dialect (i.e., dialect=mysql, or
dialect=oracle, etc...).

  Then, you can load the common sqlmaps from a common location, and the
dialect specific ones using that dialect as part of the resource path:

  <sqlMap resource="com/elm/system/dao/sqlmap/common/Employees.xml" />
  <sqlMap resource="com/elm/system/dao/sqlmap/${dialect}/Employees.xml" />

  Currently, I think there is a bug that will replace mapped statements that
are in common with any that are redefined in ${dialect} *IF THEY ARE IN THE
ORDER ABOVE*. Be warned that this behavior is considered a bug and may not
work in future releases.

  You may have to mess with it a bit, but I think it will work for you.

  When (and if) we fix that bug (and it may not be until iBATIS3 is real)
you may have to change your strategy a bit to use the fixed release - we
have talked about this functionality before, but have not had enough people
who needed it to address it. If we do fix it, we will most likely make a way
to define which mapped statement to use when there are duplicates.


  On 3/23/06, Davide Rogora <drogora@unionefiduciaria.it> wrote:
    Hi all,
    my company is starting a new data-centric application that should be
database-indipendent (e.g. work with MySql, Oracle, SQL-Server, DB2 ecc.).
    We don't want to use Hibernate because we used it in the past e we dont'
like it.
    I've found iBATIS, read the documentation and I like it because it's a
very practical and flexible framework!

    Now I need to understand how implement the database-independent
    I think that some sqlMap files could be in common (for example if the
SQL used in them is compatible with all the databases) and some other sqlMap
files could be specific of a single database.

    The perfect for us is if we could put all the sqlMap files (commons and
database-specific) in the project, an then have a flag  that switch all the
application to use the correct sqlMap files for the underlined database.

    Is there a pattern to achieve it?

    Thanks in advance (and sorry for my english)

View raw message