Working with legacy database – a challenge in Groovy

One of the most important topics in Groovy and Grails is
“Managing legacy tables for 1:M, M:M relationship and using composite keys (without using separate id field or manipulating Hibernate mapping files)”
We had to struggle with legacy database and Grails and finally came up with some kind of crude solution. This requires a lot of manual intervention and I definitely would not call it a simple CRUD as other Groovy-Grails application. Are there any good pointers to the topic of legacy database?

I received a few replies which say the January and February issues of GroovyMag have articles on the “Legacy database from Hell”. There is also a lot of information about this in Grails in Action. Many use static mappings. Your mileage will vary depending on how far your database deviates from the Hibernate norm. The Grails user mailing list a useful resource for answering specific database mapping questions. As for ROI, there is a one-off hit in advance associated with the legacy mapping, but you gain the advantage of the dynamic finders, transactional services, GSPs, and other benefits.

On the legacy mapping front, I don’t think the GORM mapping DSL supports every feature of Hibernate, so you may have to map some of your classes using Hibernate XML mapping files. It’s not pleasant, but at least you only have to do it once.

Some resources :

1. “The Definitive Guide to Grails” (2nd edition) by Graeme Rocher and Jeff Brown has a whole chapter on integrating legacy databases and Grails using Hibernate (re-mapping keys and relationships etc).

2. This link provides very easy to use sample code and straightforward tricks.
http://denistek.blogspot.com/2009/12/grails-and-legacy-database.html

3. Mastering Grails: Grails and legacy databases – Can convention over configuration survive unconventional databases schemas? http://www.ibm.com/developerworks/library/j-grails07158/index.html

Advertisements

One thought on “Working with legacy database – a challenge in Groovy

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s