Chapter 25. iBatis

25.1. Introduction

The SqlMapClient (iBatis) Gps Device provides support for database indexing through the use of Apache iBatis ORM mappings. The device can index the database data using a set of configured select statements. Mirroring is not supported, but if Spring is used, Compass::Spring AOP can be simply used to add advices that will mirror data changes that are made using iBatis DAOs.

25.2. Index Operation

When using iBatis and it's SqlMapClient, the application has several sqlMap configuration files. The sqlMap configuration usually holds configuration for a specific class, and holds it's respective insert/update/delete/select operations. The Compass iBatis support can use the select statements to fetch the data from the database. When creating the SqlMapClientGpsDevice, an array of select statements ids can be supplied, and the device will execute and index all of them. If the selects requires parameters as well, an additional array of Object parameters can be supplied, matching one to one with the select statements.

25.3. Configuration

Here is a code sample of how to configure the SqlMapClient (iBatis) device:

Compass compass = ... // set compass instance
SingleCompassGps gps = new SingleCompassGps(compass);
CompassGpsDevice ibatisDevice = new SqlMapClientGpsDevice();
SqlMapClient sqlMapClient = ... // set sqlMapClient instance
ibatisDevice.setName("ibatis", sqlMapClient, new String[] {"getUsers", "getContacts"});
.... // configure other devices