wood burning stoves 2.0*
The moose likes Groovy and the fly likes Working with legacy database - a challenge in Groovy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Working with legacy database - a challenge in Groovy" Watch "Working with legacy database - a challenge in Groovy" New topic
Author

Working with legacy database - a challenge in Groovy

Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

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?

===Vyas Sanzgiri===
My Blog
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Are there any examples of this approach in the Grails 1.0 Web Application Development book?
Matthew Taylor
Rancher

Joined: Jun 13, 2004
Posts: 110
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.


Grails Consultant
http://dangertree.net
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Can you please share some code? Do you have any examples in your blog?

I do not subscribe to those magazines but I tried other Groovy books including Grails in Action and I am still struggling. Is there a new edition of the book?
Matthew Taylor
Rancher

Joined: Jun 13, 2004
Posts: 110
Googling "grails legacy database" gave me this very informative article on the first page of results.
Jon Dickinson
Author
Ranch Hand

Joined: Feb 24, 2009
Posts: 45
Hi Vyas,

The Grails Web Application Development book does not cover working with legacy databases.

Thanks,
Jon.


Jon Dickinson
Accolade Consulting
Grails 1.1 Web Application Development
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Looks like there are more resources available than what I started out 6 months back. I will check out the links

Thanks!
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

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
Peter Ledbrook
author
Greenhorn

Joined: Jul 15, 2009
Posts: 25
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.

Cheers,

Peter
chris webster
Bartender

Joined: Mar 01, 2009
Posts: 1617
    
  13

"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).


No more Blub for me, thank you, Vicar.
Peter Ledbrook
author
Greenhorn

Joined: Jul 15, 2009
Posts: 25
Just to avoid confusion, Grails in Action also has a chapter on legacy database integration

Peter
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

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 Wang
Ranch Hand

Joined: Jan 23, 2004
Posts: 81
I'd be surprised if people are still struggling with Grails + Legacy Database. This link provides very easy to use sample code and straightforward tricks.
http://denistek.blogspot.com/2009/12/grails-and-legacy-database.html
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

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!
Denis Wang
Ranch Hand

Joined: Jan 23, 2004
Posts: 81
Do you mind to share your sample code here?
I run into the same issue and look for a solution now.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Working with legacy database - a challenge in Groovy
 
Similar Threads
Grails ready for enterprise world?
groovy vs grails
Turn this Java into Groovy!
Groovy vs. Rails question
Is Groovy just a syntax suger