Multi DB vendor configuration

119 views
Skip to first unread message

Ross G

unread,
Jan 13, 2016, 4:50:19 PM1/13/16
to mybatis-user
I'm implementing a multi DB vendor environment. I've read the documentation for multi vendor support as well as the original feature proposal: http://mybatis-user.963551.n3.nabble.com/Feature-Multiple-Database-Vendor-Version-Support-td3120608.html

In the feature proposal, there's an option to set the databaseId on the environment setting, like so:
     
<database id="myId" />

This way, whenever using that environment, MyBatis would use SQL for that databaseId. 

It doesn't appear this made it into the code and we implement DatabaseIdProvider instead.

My question is, is this correct and if so why? 

If I have 2 environments, say SQL Server and Oracle, and I'm setting which to use like so: 
sessionFactory = sqlSessionFactoryBuilder.build(reader, "oracleEnvironment")
I already know the vendor and I should be able to manually bind SQL to that environment instead of implementing the interface. 

Jose María Zaragoza

unread,
Jan 13, 2016, 5:29:14 PM1/13/16
to mybati...@googlegroups.com
Right.
You can use this code for selecting the right datasource.
If you only use a common ANSI SQL syntax supported by all your
databases in your mappers, you don't need anymore
But if every database uses its own SQL extended, you need to select
the right sentence according databaseId

To be honest, I've never used multivendor db support , but MyBatis doc is clear

Regards



>
> --
> You received this message because you are subscribed to the Google Groups
> "mybatis-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mybatis-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages