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?
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. I've been very successful doing this type of thing in the past using static mappings.
Checking this out in the context of Groovy in Action book and the latest version 1.1. We are really struggling to apply groovy and grails out of the box to legacy db. We are researching and doing more work than prob Java. Feel that there is no ROI
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.
The last 2 posts by Peter and Chris have been awesome. I have been looking out for stuff wrt legacy db. For us it doesnt make sense to change the db structure for Grails but we need something similar. I will go thru the links
You are right Peter, we have been using Hibernate XML mapping files and ROI is still under question
Denis, as I said earlier...you are talking about very simple legacy tables. In any enterprise environment we expect complex primary keys - composite keys, Keys which are not string but complex objects.
Grails - out of the box does not support this nor do the plugins. I have to change lot of code in the controller for the CRUD to work. Don't even talk about the plugins!
Joined: Jan 23, 2004
Do you mind to share your sample code here?
I run into the same issue and look for a solution now.
subject: Working with legacy database - a challenge in Groovy