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 ...
Get Grails 2: A Quick-Start Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.