O'Reilly logo

Grails 2: A Quick-Start Guide by Ben Klein, Dave Klein

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

One-to-One Relationships

In Figure 3, Diagram of the TekEvent class, the organizer property is shown as a TekUser, but in our current TekEvent, it’s still a String. Now that we have a TekUser, we can fix this discrepancy. Let’s open TekDays/grails-app/domain/com/tekdays/TekEvent.groovy and change the organizer from a String to a TekUser:

model.0.2/TekDays/grails-app/domain/com/tekdays/TekEvent.groovy
 
String​ city
 
String​ name
*
TekUser organizer
 
String​ venue
 
Date​ startDate
 
Date​ endDate
 
String​ description

We have now joined the TekEvent and TekUser classes in a one-to-one relationship. Each TekEvent instance can have exactly one TekUser. That was simple enough; however, if we save this and try to run our application, we’ll get ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required