Using Grails Object Relational Mapping (WebEffort blog)

October 21st, 2008

Original Source

The Web Effort blog has published a short article regarding relationship mappings with GORM. This is a good source to get you acquainted with the several options provided by GORM to map relationships between domain classes.

GORM is the Object Relational Mapping (ORM) implementation in Grails, implicitly Grails uses Hibernate, it is used to map the domain classes as tables in database, including their relationships.
Relationships define how domain classes interact with each other.

There are five types of relationships:

Each type is describe in a concise manner, including diagrams, a code exmaple and some tips you have to take into account to get the most of them. A reminder must be made regarding many-to-many mappings, it is often times suggested that you create a third domain class that represents the relationship between the other two, as in many cases you will discover properties that belong to the relationship, those properties can be easily added to the third domain class.

Mastering Grails: Testing your Grails Application (Scott Davis)

, October 15th, 2008

Original Source

Another great piece by Scott Davis on his Mastering Grails series, he now tackles Testing a Grails application. Everyone knows testing is important but when in crunch mode it is a task that is most often than not relegated to another cycle, sometimes it even falls from the schedule/planning and never comes back. Scott has shwon us that doing web application development with Grails is indeed easier and more productive, you can bet the test story in Grails is also improved.

I’m a huge advocate of test-driven development (TDD). Neal Ford (author of The Productive Programmer) says that “it is professionally irresponsible to write code that isn’t tested” (see Resources). Michael Feathers (author of Working Effectively with Legacy Code) defines “legacy code” as any software that doesn’t have a corresponding test associated with it — implying that writing code without tests is an antiquated practice. I often say that a project should have two pounds of test code for every one pound of production code.

Mastering Grails hasn’t yet covered TDD because the series has concentrated until now on ways to take advantage of core Grails functionality. There’s a modest bit of value in testing infrastructure code (that is, code that you didn’t write), but in practice I rarely do it. I trust Grails to render my POGOs to XML correctly, or save my Trip to the database when I call trip.save(). The real value proposition of testing comes into play when you are validating your own custom code. If you write a complex algorithm, you should also have one or more complementary unit tests to prove that the algorithm does what it says it does. In this article, you’ll see how Grails enables and encourages you to test your application.

Grails, being an agile web development framework for the Java platform, comes with a good level of testing support. Every time you create a domain class, controller or service via one the create commands you’ll also get a skeleton test case for that artifact as well, you just need to fill in the blanks. Grails also provides a separation between unit testing and integration testing, which Scott explains very well. And don’t forget that unit tests are executable documentation.

Tags: ,

Grails Podcast Episode 68: Newscast for Oct 12, 2008 (Sven Haiges & Glen Smith)

, October 12th, 2008

Original Source

We know, we wanted to discuss the Grails Testing Plugin but we had some difficulties finding a lot of time and getting the latest version installed. So we decided to discuss the outcome of the Groovy Awards instead.

Groovy Award Winners

  • Peter Ledbrook (http://www.groovyawards.org/nominate/show/peter-ledbrook)
    … for Mailing List support and plugin authorship (JSecurity, GWT, Profiling, Remoting, Testing)

    Marc Palmer (http://www.groovyawards.org/nominate/show/marc-palmer)… for the Documentation
    … for the Plugins (Feeds, Mail, Authentication, Postcode, Static Resources, Grails documentation)

    Danno Ferrin (http://www.groovyawards.org/nominate/show/danno-ferrin)

    … for Griffon (probably the biggest thing to come out this year)

    Marcel Overdijk (http://www.groovyawards.org/nominate/show/marcel-overdijk)

    … for Prolific Plugin support (Xtemplates, I18N templates, RefCode, OpenID, YUI, Ext plugin, Sifr Plugin, PeekInGrails)

    Burt Beckwith (http://www.groovyawards.org/nominate/show/burt-beckwith)
    … for Mailing List support

Show Notes

New Podcast Feed: http://feeds.grailspodcast.com/grailspodcast

Podcast Voicemail: +1 408 3319 118 (you can listen to your recording and skip or record again after presssing #)

grailspodcast.com
http://feeds.grailspodcast.com/grailspodcast
twitter: grailspodcast
flickr: grailspodcast

Podcast Voicemail: +1 408 3319 118 (you can listen to your recording and skip or record again after presssing #)

Tags: ,

A Grails Jabber Plugin (Glen Smith)

, October 9th, 2008

Original Source

Charismatic Glen Smith is back at it again, this time with a Grails Jabber plugin as part of the sample application he and Peter Ledbrook are developing for the upcomming Grails in Action book.

You can send messages from your jabber client directly to your hubbub account, and they’ll become part of your Post history. Here’s the beast in action. Sent from a Spark jabber client in the foreground to the hubbub webapp running in the backend:

Jabbering into Hubbub

The Jabber gateway listens on the hubbub user’s jabber account (based on some good work on the feedlr blog), slurps off any incoming jabbers, and places them on a JMS queue. In due course, hubbub takes those incoming queue messages and puts them on the Post history of the user with that jabber id in their profile. Eventually hubbub will let you go both ways - jabbering you your friend’s posts as well.

As Glen notes the implementation relies on JMS, which is a topic he previously covered here and here, as a matter of fact it looks like the Jabber plugin was inspired by the JMS plugin. The plugin can be downloaded from github, Glen will post the source to grails.org soon as he resolves a packaging issue.

Tags: ,

GRag (The Grails Application Generator) 1.0 released

October 6th, 2008

Release 1.0 of GRag (the Grails Application Generator) is now available. GRag covers one particular need some Grails developers face: support for legacy databases. While creating domain classes from a few legacy tables is an easy task with GORM, it is no fun at all to do it with several, perhaps even hundreds, of tables. This is where GRag comes in, as promised on its website

You can use The GRails Application Generator (GRAG) to get started with Grails using an existing database. It will generate Grails domain objects including constraints and relations. After generating the domain objects, you can continue using Grails with all it’s power.

GRag does deliver on that promise. Now there is one less obstacle to get advantage of high productivity with Grails and legacy databases.

Tags: