-
Silly GORM tricks, part II: dependent variables
This post discusses a relatively simple topic in GORM: how to use dependent variables in a domain class. It’s simple in the sense that it’s been discussed on the mailing list, but I haven’t seen it documented anywhere so I thought I’d do so here. I started with a simple two-class domain model that I…
-
Silly GORM tricks, part I: Lists
In GORM, when one class has a hasMany relationship with another, a java.util.Set is injected into the class. Sometimes, though, I want to use a List instead in order to maintain ordering. The Grails reference documents (see section 5.2.4 specifically) discuss how to do that, but there are other issues that I needed to solve…
-
assert != assertEquals (duh)
It’s probably not great for my reputation to show how I made a very silly error, but since I did it so consistently I thought showing it might help somebody avoid it. My Groovy course materials consist of far more scripts than classes. That’s probably not surprising, given that teaching Groovy involves writing lots and…
-
Some notes about the Windows installer for Grails
This isn’t really a problem, but I don’t think it’s documented anywhere, so I thought I’d record it here. (And by the way, if your reaction to my Windows-based comments is going to be “why not use something other than Windows,” my answer is (1) at least one of my machines is always running Windows,…
-
Integration tests of controllers in Grails
The documentation on doing integration tests of controllers is a bit thin. I had to ask on the mailing list about how to do some of the basics, so I thought I’d make a record of the results here. First of all, Grails distinguishes between unit tests and integration tests, in that integration tests involve…
-
Using Groovy to determine Unicode characters
(Technically speaking, this post doesn’t require Groovy. You could do the same thing in Java. Still, as usual, Groovy is easier.) I’m teaching a Groovy course this week and having a great time doing it. One of the exercises I put together is to create a concordance, which is a map relating individual words to…
-
Turning Java enums into Groovy ranges
It turns out that it’s easy to turn a Java enum into a type that can be used in a Groovy range. Consider a simple enum representing the seasons: public enum Season { WINTER, SPRING, SUMMER FALL } Since enums implement the Comparable interface, they have a compareTo() method. Despite that, however, you can’t use…
-
Nothing makes you want Groovy more than XML
I’m in Delaware this week teaching a course in Java Web Services using RAD7. The materials include a chapter on basic XML parsing using Java. An exercise at the end of the chapter presented the students with a trivial XML file, similar to: <library> <book isbn=”1932394842″> <title>Groovy in Action</title> <author>Dierk Koenig</author> </book> <book isbn=”1590597583″> <title>Definitive…
-
A few 2GX notes
Late last night I returned home from the Groovy/Grails Experience (2GX) in Reston, VA. I met many wonderful people and learned tons of new things, which I’m sure will spawn blog posts over the next few weeks. Just to get started, though, I thought I’d mention a few random observations from the conference. Buy Scott…
-
Additional comment about GRAILS_HOME
Yesterday I commented on how I needed to change my GRAILS_HOME variable to point to the grails subdirectory of the grails-1.0 distribution. I did a bit more checking and discovered something interesting. I’ve been using the Windows installer for Grails. I like how it also installs links for all the JavaDoc documentation, how it includes…