A Techie Writer's Block

Programming to go!


Leave a comment

Getting a list of collections in JPA domain classes in Grails

It’s my first time using non-Groovy JPA domain classes since we had to generate the domain classes from pre-existing database tables.

Now, in our system, the requirement is that I had to get certain details in the join tables – which are represented as Collection objects in the domains… only thing is, I’ll only know which set of tables to query at runtime. So, yes, it’s the inevitable use of reflection, something that I’m not really fond of ;p

Anyway, enough of that drama.
Continue reading


Leave a comment

Java domain classes with Grails

After a couple of months dealing with RCP development, I find myself back in familiar territory… sort of.

Coming back to Grails, I discovered that not only has it updated STS to GGTS (the IDEs), I now have to deal with version 2.2.x rather than 2.0.x when I started RCP development! O.o

Those minor issues aside, once I fired up the new GGTS in my desktop (finding a couple of bugs in the process… lol anything new?), I found out from my specifications that I had to do things a little… unconventionally.

Traditionally, when Grails apps are created, you first generate your domain classes then go from there to your controllers, services and views. This time around though, the database was already created… complete with data!

Long story short… I had to come up with a way to create the domain classes for an existing database without those domain classes interfering with the current DB’s schema and data.

Good thing we can do it with good ol’ Java objects!
Continue reading