Guest User

Untitled

a guest
May 26th, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. Grails - Preventing a recursive one-to-many relationship
  2. class TreeNode {
  3. String name
  4. String description
  5.  
  6. static hasMany = [childNodes: TreeNode]
  7. }
  8.  
  9. static constraints = {
  10. childNodes(validator: {value, obj, errors->
  11. if(value.contains(obj) {
  12. errors.rejectValue('childNodes', 'Cannot contain self')
  13. }
  14. }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment