Skip to content

Instantly share code, notes, and snippets.

@graemerocher
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save graemerocher/d31648899fdb461609fb to your computer and use it in GitHub Desktop.
Save graemerocher/d31648899fdb461609fb to your computer and use it in GitHub Desktop.
@Grab("org.grails:gorm-hibernate4-spring-boot:1.0.0.RC2")
@Grab("com.h2database:h2:1.3.173")
import grails.persistence.*
import org.springframework.transaction.annotation.*
@RestController
class PersonController {
@RequestMapping("/")
List<Person> home() {
Person.list().collect { [firstName: it.firstName, lastName:it.lastName] }
}
@Transactional
@RequestMapping("/create")
Map createPerson() {
def p = new Person(firstName:"Bart", lastName:"Simpson")
p.save()
[firstName: p.firstName, lastName:p.lastName]
}
}
@Entity
class Person {
String firstName
String lastName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment