Using GORM To Move Data Between MySQL And Couchdb – Part 1

Couchdb can run on Android and easily sync with a server in the cloud. It’s a great solution for providing apps that work “offline”. But I’m fairly new to Couchdb and the whole nosql thing. And actually, I when I first started coding we used flat files. Relational databases and SQL made life much better. So I’m a still a bit skeptical about nosql. But the offline/online sync is something I really need.

Couchdb will give me the sync that I need. But so far reporting off nosql is at least behind from what I can tell. So I’d like to use Couchdb (probably with a couchapp) on the mobile side and have the data normalized and put into MySQL where I can work in familar surroundings.

And since my preferred development environment is Grails with its all-powerful GORM, I have an idea. There’s a Couchdb plugin for Grails that will use GORM to create databases and documents from domain classes. And of course, it creates MySQL tables and records. So it seams feasible that I can create a Grails plugin that will take Couchdb documents, normalize them and put their data into MySQL.

I’d certainly appreciate any feedback on this idea.

[Slashdot] [Digg] [Reddit] [] [Facebook] [Technorati] [Google] [StumbleUpon]

Calling A Service From The Grails Console

I’m doing my first project in Grails and intend to blog some of thing things I’m learning.

During development, the grails console is very useful for testing specific pieces of code without having to go through your whole system to get to that particular bit of code.

For the most part, you can just enter grails commands and hit execute. But apparently dependency inject doesn’t happen in the console. So there’s a bit of a trick to execute a service from the console.

If you had a service named MySecretService with a function named secretSquirell, you could access it via dependency injection in a domain class, a controller or another service by first adding

def mySecretService

then later you can say
def result = mySecretService.secretSquirell()

But to test in the console you need to do this:

def service = ctx.getBean("mySecretService")
def result = service.secretSquirell()

[Slashdot] [Digg] [Reddit] [] [Facebook] [Technorati] [Google] [StumbleUpon]