IntelliJ open source
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Win a copy of Flex 4 in Action this week in the Flex forum!
Reply Bookmark it! Watch this topic JavaRanch » Forums » Other Languages » Groovy
 
RSS feed
 
New topic
Author

Working with legacy database - a challenge in Groovy

Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Messages: 540

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
Messages: 540

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

===Vyas Sanzgiri===
My Blog
Matthew Taylor
Rancher

Joined: Jun 13, 2004
Messages: 108

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
Messages: 540

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?

===Vyas Sanzgiri===
My Blog
Matthew Taylor
Rancher

Joined: Jun 13, 2004
Messages: 108

Googling "grails legacy database" gave me this very informative article on the first page of results.

Grails Consultant
http://dangertree.net
Jon Dickinson
Author
Ranch Hand

Joined: Feb 24, 2009
Messages: 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
Messages: 540

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

Thanks!

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

Joined: Jun 16, 2007
Messages: 540

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

===Vyas Sanzgiri===
My Blog
Peter Ledbrook
author
Greenhorn

Joined: Jul 15, 2009
Messages: 24

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

Joined: Mar 01, 2009
Messages: 74

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

Joined: Jul 15, 2009
Messages: 24

Just to avoid confusion, Grails in Action also has a chapter on legacy database integration

Peter
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Messages: 540

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

This message was edited 1 time. Last update was at by Vyas Sanzgiri


===Vyas Sanzgiri===
My Blog
Denis Wang
Ranch Hand

Joined: Jan 23, 2004
Messages: 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
Messages: 540

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!

===Vyas Sanzgiri===
My Blog
Denis Wang
Ranch Hand

Joined: Jan 23, 2004
Messages: 81

Do you mind to share your sample code here?
I run into the same issue and look for a solution now.
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Other Languages » Groovy
 
RSS feed
 
New topic
The most intelligent Java IDE