More About Domain Classes

Now we have a persistent TekEvent class. We can create instances of this class and save them to the database. We can even find existing instances by their id or by their properties. You might be wondering how that can be—where is the code for all this functionality? We’ll learn more about that when we start using these features, but the short answer is that Grails uses Groovy metaprogramming (which we discussed in Metaprogramming) to dynamically add powerful behavior to our domain classes. As we get further in developing our application, we’ll see that we can call methods like TekEvent.save(), TekEvent.list(), and TekEvent.findAllByStartDateGreaterThan(new Date() - 30), even though we’ve never written any code to ...

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.