Using different data sources for specific requests with Spring and IBATIS

I have a requirement to update my application to use multiple (i.e. two in this case) data sources depending on the type of request. For example, use DB1 for reading and DB2 for writing. How do I approach this?

+2


source to share


1 answer


We did this by creating two SqlMapClients, one for reading and one for reading / writing. Each one has its own sqlMapConfig file. We split our sqlMap resources into read and write pairs, i.e. Account.xml and Account-Write.xml. Read-only sqlMapConfig loads read-only sqlMap resources, and sqlMapConfig read-write loads both read and write resources.



It seems to be good. If you are in a read-only transaction, you are using a read-only SqlMapClient, otherwise you are using a read-write SqlMapClient.

+3


source







All Articles