mainstringargs
mainstringargs

Reputation: 13923

GORM for Rest (Grails)?

I am doing some research on Grails and writing about what the future holds for it..

Something interesting jumped out in the RoadMap (http://grails.org/Roadmap)

GORM for REST

Anyone with more experience with Grails than me know what this would entail?

I am guessing some sort of CRUD operations through Web Services instead of using Hibernate to connect to an SQL database?

Upvotes: 15

Views: 1806

Answers (4)

tolitius
tolitius

Reputation: 22549

there is a JSON RESTful API for GORM which gives some insight on what GORM for REST is like:

  • GET on /context/api/domain-class-name returns a list of domain objects (possible arguments are the same as for the DomainClass.list() method argument map)
  • POST on /context/api/domain-class-name creates a new instance
  • GET on /context/api/domain-class-name/id retrieves the given instance
  • PUT on /context/api/domain-class-name/id updates the given instance by ID
  • DELETE on /context/api/domain-class-name/id deletes the given instance

As far as to RESTy GORM that is scheduled for Grails 2.0, here is the GORM Virtual REST domain objects discussion on Grails mailing list:

I am currently evaluating the use of grails to connect to other backend systems. Would it be possible to let the domain layer talk to CRUD REST services instead of a Database? It would be a bit like a XML backend.... We have got a very big backend where it is difficult to implement business logic, but we can manage to provide restful services. My idea is to have grails as a business / web application layer on top to deploy various systems to cross platform

This feature is scheduled for development for Grails 2.0 
-- Graeme Rocher

Upvotes: 7

Ganesh Krishnan
Ganesh Krishnan

Reputation: 7395

Not that I want to rain on the parade but why would I use REST for accessing database rather than directly through hibernate. It's bound to slow down the DB access.

Upvotes: 0

chrislatimer
chrislatimer

Reputation: 3560

I think the intent is to apply the scaffolding pattern to a RESTful API out of the box. There has been a JIRA entry around for several years for this.

Resulting JIRA: http://jira.grails.org/browse/GRAILS-2823

I also wouldn't be surprised if they took the dynamic finder idea and applied it to URL patterns.

GET /book/findByTitle/Dune

or

GET /book/findByTitle?title=Dune&format=json

or something like that.

I don't know exactly what is on the roadmap, but I imagine that the final product will have scaffold functionality (list,view,create,update,delete) through a RESTful interface plus some URL patterns that correspond to what you can currently do with the dynamic finders that GORM provides.

Upvotes: 6

Eric Turner
Eric Turner

Reputation: 1824

Take a look at the JAX-RS plugin. I suspect that will be the kind of thing they use.

Upvotes: 0

Related Questions