We have been using Grails framework for quite some time and are absolutely thrilled with it! As with any emerging platform, integration with existing development and deployment strategies can prove challenging. While developing applications for our customers, a need arose for Grails platform customization. The result of our work with Grails in enterprise development are two open source plugins published on www.grails.org.
MyBatis Grails plugin
Most enterprise applications are data driven, and integrating new development with existing applications can prove difficult due to data model inconsistency. Using built-in Grails ORM (GORM) with legacy database model is not as straight forward as official documentation would suggest. One of the best alternatives to full featured ORM (Hibernate/GORM and JPA) is MyBatis (formerly Apache iBatis).
Advantages of using MyBatis over GORM is ability to write custom SQL queries and object mappings for each specific case.
Existing Grails plugin for iBatis was not compatible with Grails 2.x version, didn’t support multiple datasources, and wasn’t maintained with later version of MyBatis. Due to original plugin author non-responsiveness we reimplemented plugin with newer MyBatis version and added features which include:
- support for optimistic locking
- multivendor database support
- ability to use MyBatis dynamic SQL with ‘_databaseId’ variable
- automatic handling and registering custom TypeHandlers
Datasource JNDI declare Grails plugin
Grails developers intended for Grails application to be platfrom independent as much as possible, but in their good intentions they limited one important feature in enterprise deployment. While Tomcat and similar containers support JNDI datasources, they don’t support JNDI name mappings.
War packaged Grails applications which use JNDI datasources don’t declare them in web.xml application descriptor. This plugin scans Grails application configuration and adds JNDI resource declarations in web.xml for each JNDI datasource used.
Have fun!