-
-
Save graemerocher/d31648899fdb461609fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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