Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Grails - Preventing a recursive one-to-many relationship
- class TreeNode {
- String name
- String description
- static hasMany = [childNodes: TreeNode]
- }
- static constraints = {
- childNodes(validator: {value, obj, errors->
- if(value.contains(obj) {
- errors.rejectValue('childNodes', 'Cannot contain self')
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment