2 Getting Started - Reference Documentation
Authors: Franjo Žilić
Version: 0.0.3
2 Getting Started
Installation
Add plugin dependency to BuildConfig.groovycompile ":mybatis:0.0.3"
UnInstall
Remove plugin dependency from BuildConfig.groovy and remove directories grails-app/gateways and grails-app/typeHandlersWorkspace configuration
If you are using SpringSource Tool Suite or IntelliJ Idea as your IDE you should add grails-app/gateways and grails-app/typeHandlers to your source path for class resolution.Configuration
None of configuration options is required for starting application with this plugin, but you should modify them to suite your own applicationOption | Description |
---|---|
mybatis.dataSourceNames | List of datasource names used for MyBatis |
mybatis.optimisticLocking | Enable OptimisticLockingInterceptor globally |
mybatis.multivendor.enabled | Enable support for multiple database engines |
mybatis.multivendor.mapping | Map multiple database engines to specific MyBatis database ids |
DataSource configuration
To support multiple datasources you have to configure which ones are going to be used by MyBatis plugin.By default plugin uses only default datasource and each gateway artefact is registered to default datasource. If you wish to use more then one datasource add their names to this list.mybatis.dataSourceNames = ['dataSource']
Optimistic locking configuration
Optimistic locking is enabled by default on all datasources but no object will be versioned unless they are configured with a static field. To change optimistic locking functionality add this to your configuration.mybatis.optimisticLocking = false
Multivendor database support
If you wish to support more then one database vendor you have to enable support in plugin configuration and map different database names to a specific databaseId key. For more information about multivendor support in MyBatis consult MyBatis documentation. Sample configuration and use is provided in this documentation.mybatis.multivendor.enabled = true
If you choose to implement multivendor support you have to map database names to distinct ids. This is a sample configuration which provides mapping for couple of database namesmybatis.multivendor.mapping = [ 'Microsoft SQL Server': 'mssql', 'H2': 'h2', 'Informix Dynamic Server': 'informix', 'DB2/LINUXX8664': 'db2', 'DB2/400 SQL': 'db2' ]