Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Class
- class Book {
- static hasMany = [:authors => Author]
- Author author
- String name
- String email
- static constraints = {
- name :validate => { it.size() > 30 }
- email :email => true, :blank => false
- }
- String toString() { "$id: $name" }
- }
- // Aspect
- aspect Book {
- declare @Entity Book.class
- }
- // Aspect
- aspect Lister<T> {
- in template
- declare static List<T> *.list(int max=-1, int offset=0) {
- template.list(T, max, offset) as List<T>
- }
- declare T *.get(Long id) {
- template.get(id) as T
- }
- declare T findBy/s/() {
- /* return */ template.execQuery(s.convertToQuery())
- }
- }
- // DI
- objects {
- SessionFactory sessionFactory {
- wire = :byType
- }
- HibernateTemplate template {
- sessionFactory = sessionFactory
- }
- }
Add Comment
Please, Sign In to add comment