GeeCON Prague 2014*
The moose likes Groovy and the fly likes Grails and legacy database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Languages » Groovy
Bookmark "Grails and legacy database" Watch "Grails and legacy database" New topic
Author

Grails and legacy database

Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

As far as I have experience with Grails you have to start from the database. I had lots of issues working with a legacy database. If I solve them - the plugins also need some work.

I really don't think I want to model my database with ids but any database has complex composite keys and relationships. I found this really hard to model in Grails. Rather I would have taken half the time to do it in Spring.

Does Grails: A Quick Start Guide talk about legacy database design? What do you think is the best strategy?


===Vyas Sanzgiri===
My Blog
Kenneth A. Kousen
gunslinger & author
Ranch Hand

Joined: Sep 18, 2002
Posts: 89
    
    5
I'm sure Dave will answer this, but since you asked, let me give you my take. Grails is based on Hibernate (and Spring, and SiteMesh, and ...). Databases that can be mapped cleanly with Hibernate work quite well with Grails. Databases that cause Hibernate problems will also cause Grails problems.

That said, Grails comes with an excellent custom mapping DSL (domain specific language). Take a look at the "Custom ORM Mapping" section of the Grails documentation, at http://grails.org/doc/latest/ for details.


Kenneth A. Kousen, Ph.D. (assorted certs), President, Kousen IT, Inc.
Author of Making Java Groovy - http://www.kousenit.com
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

I tried that but the most plugins fail if I do that and then I have to write custom code for every single CRUD operation. In short, there is no rapid development.
Kenneth A. Kousen
gunslinger & author
Ranch Hand

Joined: Sep 18, 2002
Posts: 89
    
    5
I'm surprised to hear that. Plugins are supposed to follow the custom mappings. What plugins are giving you trouble?

On a more practical note, there is a very active Grails user email list. Most of the core team follow it. You might consider posting your specific question there. All of the Groovy email lists are described on http://groovy.codehaus.org/Mailing+Lists .
Dave Klein
author
Ranch Hand

Joined: Aug 29, 2007
Posts: 77
I've used the ORM mapping DSL to access a legacy Oracle database and it worked great. I didn't have any compound keys, but I've heard of others that have and it should work. Perhaps you could post a sample of your schema and your mapping code here, or, as Ken suggested, on the Grails mailing list.

Dave
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

searchable
filter pane
export
some more...

I have composite primary keys which are foreign keys. Some tables are not in the domain and I don't want to include them in the domain. In such cases, I have to manually create connections and check that the constraints are satisfied.

My point is - if I have to manually add so much code to take care of normal CRUD operations how is it "rapid"
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Vyas Sanzgiri wrote:My point is - if I have to manually add so much code to take care of normal CRUD operations how is it "rapid"


It might not be. And for your project Grails might not be the best fit. Thankfully, in the java world, we have a lot of choices. Anyone who says [Framework XYZ] is the best is just fooling themselves. Grails is great when it makes the most sense for a given project. It could also be the worst possible solution.


GenRocket - Experts at Building Test Data
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

ok I get what you are saying! I tried a couple of complex applications in Grails with my legacy db.
 
GeeCON Prague 2014
 
subject: Grails and legacy database