Putting Entities to Rest with Groovy, Hibernate, and JPA
May 09, 2007
I mentioned in my previous entry about how I am totally sold on Groovy. I immediately went off and converted a couple of shell scripts that I use daily into Groovy scripts. I was pleasantly surprised by the CliBuilder for processing command-line arguments, but that is another story. What I am really excited about is what I was able to do next. While perusing Java Persistence with Hibernate, I started thinking about how Groovy might make object-relational persistence easier. I tend to dread working with Hibernate or JPA just because it takes a while to get it all setup, usually requiring the formal step of setting up a project in Eclipse.
That is where our story begins. The challenge: How hard is it to use Groovy to persist an entity class? The answer: Amazingly simple. So simple, in fact, that there is almost no reason to access the database any other way (unless you are a database purist and then you have your reasons). For me, I prefer the Hibernate or JPA route, if I can take it.