Fork me on GitHub

29 Jun 2010

Acyclic relationship validation in Grails

A common domain class use-case is for a self-referential relationship that must not be circular (a directed acyclic graph). For example, a Person class may have a parent property that is a many-to-one relationship with another Person instance. However a given Person cannot be his own parent or ancestor.

We're using just such a relationship for trees of pages that inherit certain characteristics from their ancestors. In order to validate that our users aren't setting up circular references I implemented the following constraint:Then I just needed to register my new constraint by adding ConstrainedProperty.registerNewConstraint(AcyclicConstraint.NAME, AcyclicConstraint) to grails-app/conf/spring/resources.groovy. Using the constraint is as simple as this:
class Person {

    String name
    Person parent

    static constraints = {
        parent acyclic: true
    }
}
The constraint can be mixed with others such as nullable: true. The really nice thing is that the constraint implementation doesn't reference any of my domain classes directly, meaning it can be re-used in any other domain class.

When you're using similar validation logic in multiple classes defining a constraint like this is a much better option than using a validator closure and like many things in Grails it turns out to be pretty easy to implement.

76 comments:

johnrellis said...

awesome! this constraint should definitely be added to the grails source, i reckon it is one that is enforced in all wacky ways in other projects. Adding a constraint looks nice and easy!

dustmite said...

Nice work! Custom constraints in Grails are very powerful. Wonder if this could be extended to look beyond direct relationship and make sure that someone isn't say their own great great grand child or such.

Rob said...

@dustmite it's already doing that

dustmite said...

@Rob Sorry, I noticed that after posting my comment. Really great stuff, took it for a spin last night and works like a charm.

As @johnrellis said this should be included with the Grails source.

Rick Jensen said...

Please, as others have said, get this included in Grails core. It's a sufficiently complex validation that is easy to mess up and is also very common.

Unknown said...

Jadwal Bola | Permainan Bola | Judi Bola | Taruhan Bola | Agen Bola | Agen Sbobet | Jasa SEO Profesional | Jasa SEO | Harga Jasa SEO Profesional | Jasa SEO Murah | Pakar SEO

Anonymous said...

338a | agen bola | agen sbobet | bola tangkas | casino sbobet | liga champion | prediksi bola | cool mobile gagdet

Anonymous said...

sbobet | ibcbet | agen bola | agen bola Terpercaya | Jasa SEO Profesional | Jasa SEO | Harga Jasa SEO Profesional | Jasa SEO Murah | Pakar SEO

Metamorfosis said...

Pelatihan SDM is network marketing and training information or training an employee who has worked with many consulting firms and training institutions.
pelatihan hrd,
pelatihan pengembangan diri,
pendidikan dan pelatihan sdm,
pelatihan akuntansi keuangan,
pelatihan sales marketing,
pelatihan kehumasan,
pelatihan sdm jogja,
lembaga pelatihan sdm
pelatihan manajemen bisnis,
pelatihan administrasi perkantoran,
lembaga training motivasi,
pelatihan sekretaris,
pelatihan karyawan,
lembaga training di jogja,
pelatihan in house training,
pelatihan public training,
jasa konsultan,
pelatihan pengembangan sdm,
pelatihan manajemen sdm,
program training karyawan,
diklat sdm,
pelatihan sdm untuk rumah sakit,
_____
id card murah,
harga id card,
cetak kartu santri,
produksi id card,
bikin id card,
cetak id card jogja,
id card murah jogja,
cetak id card,
percetakan id card,
pabrik id card,
cetak member card,
cetak kartu pelajar,
cetak kartu siswa,

Unknown said...

I like your stuff, classic right, Now... everything with digital, perdita di peso thanks for remind me for this memories
water heater gainsborough
water heater ariston
water heater rinnai
water heater delizia
water heater wika

Metamorfosis said...

Kursus Arab Pare is a place for all of you who want to study and able to speak arabic. Come and join us..

Tempat Kursus Bahasa Arab

شركه تنظيف said...

شركة تنظيف شقق بجازان
شركة نقل اثاث بجازان
شركة كشف تسربات المياه بجازان
شركة مكافحة حشرات بحائل
تنظيف منازل بحائل
نقل اثاث بحائل
كشف تسربات المياه بحائل

abo-bder said...


شركة شحن عفش من الرياض الي الامارات-دبي
شركة نقل اثاث من الرياض الى الامارات

شركة نقل اثاث من الرياض الى الامارات


Assignment Help said...

I loved the article, keep updating interesting articles. I will be a regular reader… I am offering assignment help to students over the globe at a low price.
Course Mentor
Assignment help
Homework Help
Coursework Help
Become Mentors
how to be a mentor
how to become a mentor
Assignment help
find a mentor
how to get a mentor
how to find a mentor
Coursework Help
Coursework Writing Service
coursework writing help
Homework Help
Help With Homework
Homework Help Service
Assignment help NZ
Assignment help UK
Assignment help US
Assignment help Australia
Assignment help Canada
Assignment help AU

Assignment Help said...

Thanks for sharing this information. I have shared this link with other keep posting such information to provide best in class law assignment help online at very affordable prices.

Assignment help
Assignment help
Assignment help
Python Programming Assignment
Programming Assignment Experts
Assignment help tutors
Assignment help

Assignment Help said...

I loved the article, keep updating interesting articles.and we serve best food according to our customers' reviews we have a specious hall for marriages & special arrangement for kitty parties and other parties. You can visit us at any time we would love to serve you.

assignment help
assignment help
online assignment help
assignment help online
assignment help australia
do my assignment
college assignment help
university assignment help
statistics assignment help
finance assignment help

Assignment Help said...

I love the article keep updating article. And we serve best food according to our customer’s review we have a specious hall for marriage & special arrangement for kitty parties and other parties. You can visit us at any time we would love to serve you.
Assignment help Australia
Australian Assignment Help
Assignment writing service Australia
Online assignment help australia
Assignment Help Brisbane
Assignment help Sydney
Assignment Help Adelaide
Assignment Help Perth
Assignment Help Melbourne
Assignment Help Canbera
Essay Writing Service australia
Nursing Assignment Help Australia
University Assignment Help Australia
Write My Essay Australia
Cheap Essay Writing Service Australia
Accounting Assignment Help Australia

Assignment Help said...

I found this one pretty fascinating and it should go into my collection. Very good work! I am Impressed. We appreciate that please keep going to write more content. We are the assignment helper, we provide services all over the globe. We are best in these:- services
dm beginners
dm beginner
digital marketing for website
digital marketing for beginner
digital marketing beginner
learn digital marketing
learn digital marketing free online
learn digital marketing free
learn seo
how to learn affiliate marketing
dm beginners
dm beginner
digital marketing for website
digital marketing for beginner
digital marketing beginner
learn digital marketing
learn digital marketing free online
learn digital marketing free
learn seo
how to learn affiliate marketing

Assignment Help said...


Many of the people are depressed about the problems of essay writing. Well, don’t worry about that because we are providing this service at a very reasonable price.

Statistics Assignment Help
Statistics Homework Help
statistics help
statistics homework
statistics homework helper
SPSS Help
SPSS Tutors
SPSS Homework Help
matlab homework help
matlab assignment help
help with matlab
stata homework help
probability assignment
probability assignment help
R Programming homework help
Bio Statistics Assignment Help
R Programming Help
R Programming homework help
business statistics assignment help
business statistics homework help

Assignment Help said...

I loved the article, keep updating interesting articles.and we serve best food according to our customers' reviews we have a specious hall for marriages & special arrangement for kitty parties and other parties. You can visit us at any time we would love to serve you.

Article Assignment Help
Essay Assignment Helper
Essay writing
Essay writing service
Dissertation help
Thesis writing help
Write My Essay
Do My Essay
Hire Cheap Essay Writer
College Essay Help

Assignment Help said...

I love the article keep updating article. And we serve best food according to our customer’s review we have a specious hall for marriage & special arrangement for kitty parties and other parties. You can visit us at any time we would love to serve you.
" Essay writing
"
Essay Writer
seo writing service
Essay writing service
Essay writing help
Write My Essay
hire seo writer
hire writer
Write my essay cheap
hire article writer

Assignment Help said...

I love the article keep updating article. And we serve best food according to our customer’s review we have a specious hall for marriage & special arrangement for kitty parties and other parties. You can visit us at any time we would love to serve you.
Assignment Help
Assignment Helper
Essay writing
Essay writing service
Dissertation help
Thesis writing help
Write My Essay
Computer Science Assignment Help
Assignment Help South Africa
Assignment Writing Service

Assignment Help said...

I loved the article, keep updating interesting articles. I will be a regular reader… I am offering assignment help to students over the globe at a low price.
verdant marriage palace
verdant Resort
marriage palace in Pehowa
Wedding Venue in Pehowa
Banquet Hall in Pehowa
Resort in Pehowa
Best Resorts near Pehowa
Best marriage palace in Pehowa
Best Family Restaurant in Pehowa
Best Veg Restaurant in Pehowa
Best Non-Veg Restaurant in Pehowa
Chawlas 2

james cook said...

It is nice to read such high-quality content. It is a good article that discusses the topic at hand quite well. I am looking forward to read more articles from your site. Keep up the good work.
assignment help uk

Hailie Hills said...

At what type of exam questions I need to pay attention more? I'm sure that at least once every student asks him/herself this question. I can recommend you to pay attention to the facts, people names, differences, and similarities. Those things will help you to recover information which you prepared before.

Puremelda said...

Many students are undecided about the best nursing research paper help Company to deal with due to the high number of companies that offer similar services.

Rebeca Thomson said...

Hello, thanks for this interesting article. I appreciate it a lot. Luckily I did my paper, with the help of this source https://essayelites.com/buy-a-capstone-project-online and now I can have some free time by reading this amazing blog post.

Alley John said...



Are you students and do not know How to write an assignment
? So do not worry about writing a good assignment because MyAssignmentHelp is providing the best assignment writing expert's for students.

acmarket said...




Thankyou for the valuable information.iam very interested with this one.
looking forward for more like this.

https://www.advnt01.com/5-ways-to-build-enterprise-mobile-apps-the-right-way/
https://www.asmallcinema.org/do-you-need-to-know-everything-about-hybrid-app-development/

https://www.cfecgc-unsa-ft-orange.org/top-6-mistakes-app-entrepreneurs-make-during-app-development-and-marketing/
https://www.theliyakebedefoundation.org/fun-and-practical-tablet-apps-for-seniors/
https://www.capriles.tv/not-all-apps-are-created-equal/






Marriot Roy said...



Connect with UAE VAT Expert for get best vat software in uae for vat return filing from professional expert’s at affordable price.

Max Willor said...

This post is not just informative but impressive also. The post is so convincing that it created an urge to choose Nursing Assignment Help services. You can email us at cs@Myassignmenthelpau.Com or Phone Number: +61-2-8005-8227

rickypauls said...

Great write-up! All doubts regarding Assignment Help solved after reading the post. Sometimes, it becomes difficult to manage the time for writing homework due to some unavoidable reasons. I have recommendation for website greatassignmenthelp for ordering best writing services to complete your academic task.
Assignment Helper
Assignment Help Online
Online Assignment Help
Assignment Help Online Services
Assignment Assistance
Assignment Help Experts
Assignment Writing Help

shashi said...

Ignouproject offer the guide books and project to the learners of the university students. Our website help those students who are working and don't have time to write their Ignou project. To help these learners we have project writing experts who write plagiarism free project which is totally customized according to the students.

meldaresearch said...

We assure you that all the best essay writers online, custom college papers, research papers and term papers that we deliver to our clients are the best in the industry and you do not need to have a second thought when buying any of our cheap paper writing service from us.

Ideal Assignment Help said...

A very high level post with a knowledgeable information .thanks you for giving me such a nice information. If you need any college level Assignment Help at reliable quality with better work. Kindly visit Ideal assignment help.

Rayan Warner said...

While working excellent the day I bring Microsoft office 365 into play, suddenly from the last couple of days, it started to throw some error while working in it. However, after taking Office 365 Support and reading the measures which are mentioned in this guide helps me to resolve my entire issues related to Microsoft 365. Get support click here
Office 365 Help
Office 365 Support
Microsoft Office 365 Support
Outlook Support
Microsoft Outlook Support
Outlook Support Number
Outlook Support Phone Number
Outlook Tech Support Phone Number
Outlook Technical Support Phone Number
Outlook Customer Service Phone Number
Outlook Customer Support Phone Number
Outlook Support Number
Microsoft Office Support
Microsoft Office Customer Service
Microsoft Tech Support
Microsoft Tech Support Number
Microsoft Tech Support Phone Number
Microsoft Technical Support Phone Number
Microsoft Technical Support Number
Microsoft Technical Support
Microsoft Office Support Phone Number
Microsoft Office Support Number

kiara Jess said...

Thank you so much for sharing this post, I appreciate your work.It was a great informative post.Go so many useful and informative links. Loved your writings also. Concept of the topic was well discussed. Love to come here again. We also provide affordable MBA Assignment help in uk.

jonas cruz said...

Thanks for sharing this information. We need such information to create CDR Reports. You can get complete CDR Report Writing Service from us. We also provide CDR Reports in Australia, Summary Statement Writing and Career Episode Writing.

ireland assignment help said...

I read this blog post and this is a really good post, so thanks a lot for sharing this good blog post, I hope to keep more post for sharing. thanks once again. assignment writer

James Wright said...

The writing experts will help the students to compose the dissertations. If you are currently looking an online dissertation help service for writing a master's dissertation proposal that can make the process of writing and submission easier, then consider working with MyAssignmentHelp - the no.1 academic writing help portal in Malaysia.

Alpha Assignment Help said...

I can only imagine how much research has gone into this. I like your writing skills as it makes one feel included in the journey. Thank you for the valuable notes.
Assignment Help
Dissertation Writing Services
Essay Writing Service
Marketing Assignment Help
Finance Assignment Help
Management Assignment Help
Cheap Assignment Help
Assignment Help Uk
Best Dissertation Writing Services
Account Assignment Help
Get Assignment Help
Assignment Help Usa
Economics Assignment Help
Academic Writing Help
accounting assignment writing service
cheap assignment writing service
get assignment help online
best assignment help online
best online assignment help

myassignmenthelp said...

My Assignment help is an incomparable online assignment help company delivering excellent academic assignments, essays, coursework and reports. Through a team of over 3000 subject experts we ensure individual attention to every student making the assignment help experience completely personalized in nature. With our round the clock services, you can be assured of high grades every time.

Alpha Assignment Help said...

I can only imagine how much research has gone into this. I like your writing skills as it makes one feel included in the journey. Thank you for the valuable notes.
Assignment Help
Dissertation Writing Services
Essay Writing Service
Marketing Assignment Help
Finance Assignment Help
Management Assignment Help
Cheap Assignment Help
Assignment Help Uk
Best Dissertation Writing Services
Account Assignment Help
Get Assignment Help
Assignment Help Usa
Economics Assignment Help
Academic Writing Help
accounting assignment writing service
cheap assignment writing service
get assignment help online
best assignment help online
best online assignment help

Expo 2020 said...

I know this is one of the most meaningful information for me. And I'm animated reading your article. But it's a good thing, the website is perfect; the articles are great. Thanks for the tone of tangible and possible help.
Skydive dubai

Keith Morris said...

I am a freelancer and have been helping a lot of students in providing assistance to students who frequently gets worried about their assessment tasks and went online to search for australia assignment help terms. We at My Assignment Services have potentially recognised the need way back and started what we are an enlarged version of then. With many assignment helper companies in the market, no one has quite able to match the standard that we follow. We give utmost priority to students by strictly adhering to the assignment requirements as well as marking rubrics to score high grades. Our Assignment uk assignment help writers are well-proficient in not only comprehending your assessment tasks but also to give an expertise finish to it. Provided a well-written assignment suitable to your needs, your search for professional essay writers will now end with My Assignment Services. You just have to visit our website for more information.

meldaresearch said...

One of the things that you will realize is that our company offers custom Nursing Research Papers for Sale that are similar to what you desire for you to improve your grade. Our writing urgency has specialized in offering Term Papers Writing Services, and we have been in the industry for a decade.

Hendy said...

I read the article, this is awesome. Keep updating interesting articles. I am offering assignment help to students over the globe at very affordable prices.
statistics assignment help
econommics assignment help
finance assignment help

ravi said...

top 10 apps in india
Best Pirate Bay Alternatives
Free Movie Apps for Android
Free Movie Apps for iPhone

Academic Assignment Writing said...

Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, we can see more on this. Are you aware of any other websites on this subject.
Dissertation Writing Services

Unknown said...

Awesome Article! I really love it. Please keep sharing the good articles. We are providing statistics assignment help, r programming assignment help, sas assignment help and many more to College and University Students over the globe.

seo company said...

Fast Social Follower will help you increase your visiliblty on social media platform such as Buy Spotify Followers

jacklinemelda said...

Look for congenial Sociology Custom Writing Services for all your Custom Sociology Paper Writing Help and Sociology Assignment Writing Services.

Alley John said...

Word Counter Tool is a free word count calculator tool to help you count and calculate the number of words in a text. This online tool can also calculate the total character or letter count, sentences, and paragraphs for the text entered in the input box. So connect with MyAssignmentHelp for getting the best Word Counter Tool.

Ideal Assignment Help said...

We are skilled at giving Engineering Assignment Help So whether you require a paper on concurrent, spread and parallel system or an amazing response for gathering the handiness, execution, cost-viability, Ideal Assignment Help is the pro community you are scanning for.

khalsa store said...

Just wanted to convey my regards. This was really a valuable experience. I will ensure that my friends also read this as soon as possible. I cannot wait to share this.

bhangra items
bhangra
artificial jewllery
jewllery
gidha
jago items
parandi
phulkari
shamiz
under shirts
naale
jura rumal
chola kids
jura rumal
kalire
churra
sehra
kalgi
garvi
rumal
surmedani
glass
sahe chitti
milani har
thelli
ribbon plate
harr
brass utensils
decoration items
1984
turbans
turban
kirpan
sikh accessories

tom554 said...

I found this is an informative blog and also very useful and knowledgeable. I would like to thank you for the efforts you have made in writing this blog.
Assignment writing

lee brown said...

My Assignment Help online helps students to achieve their goals of getting high grades in Electronics Engineering through our competent electronics engineering assignment help service. We have the pool of most expert and experienced writers, proofreaders and editors to offer 100% genuine work to our clients. If you want the same, you can contact us anytime and can discuss your assignment related issues with our writers to get desired outcome.

mike said...

Top Salesforce Consulting FirmsI really want to appreciate the way to write this article.Salesforce Consulting Company It seems that you are very professional and intelligent on the above topics of writing. Salesforce Trailhead

Best Travel Portal Development said...

Hotelspro is the leading market place where Hotels XML API integrations help the client to make travel searches directly into their websites. Teamindia webdesign provides the best Hotelspro XML API integration to help out the client to make travel searches directly into their websites.

Assignment Help Australia said...

Assignment Help is the good of getting academic writers' assistance amid of coronavirus pandemic in which we have to avoid physical contact. Stay at home and be healthy using online academic writing services for project submission in Australia.
My Assignment Help
Assignment Help Online
Online Assignment Help

get assignment help online said...


Are you looking for the best assignment help service provider than visit assignment-writing-service this is the best and cheapest service provider ever.They provide all subject services according to your requirement.

please visit
mathematics-assignment-help
law-assignment-help
biology-assignment-help
machine-learning-assignment-help

John Rock said...

Your blog is charming. I want to say; please keep it. Thank You!
Assignment Help Australia
Assignment Help
Education Assignments

mehmet said...

Güzel bilgiler paylaşmışsınız emeklerinize sağlık teşekkür ederim.

chat

chat

chat odaları

sohbet sitesi

chat odası

chat sohbet

chat odası

chat arkadaşlık

assignmentworkhelp.com said...

Assignment help that ensures that you meet the deadline every time. It is important that the assignments are written in a way that all the questions asked by your professor are answered and all the objectives are fulfilled. Our subject experts make sure that we do not deviate from the actual context of the assignment and provide the best possible solution without charging an exorbitant amount. Our fair pricing and discounts make our services even more accessible and the best choice when availing the online assignment help in Australia. We consider it a sign of discipline to meet the deadline and submit top quality work within the designated time limit. The subject experts at assignment work help deliver the required output to meet the expectations of our clients every time and make sure that you get good marks for every assignment.
best online assignment writing help
assignment solution australia
best assignment help australia
online assignment help
best assignment help
assignment help in usa
online assignment website

James Martin said...

Connect with professional academic writers via Assignment Help in Ireland to finish your papers without any issue. So, buy Online Assignment Help and complete your homework before the due dates.
Visit us : Assignment Help Online

James Marcus said...

Wow, Great blog and lovely post. The way you have chosen it and the way it is written, it is very good indeed. So please write some more related to this. I am your regular reader and I am also here for my website promotion. Whenever you need to Outlook Support and you want it from experts then contact us from our Outlook Support Phone number or Outlook customer Service Number . The outlook is an email application, which is used to send and receive emails.
Outlook technical Support Phone Number
Outlook tech Support Phone Number
How do I contact outlook by phone?
Microsoft Outlook Support
Is there a phone number for Outlook support?
Microsoft Support

Monnika Jacob said...

How can we stop loops and call for parameters? Is it possible to end loops before call to parameters? I am looking for the answer of this question. Please guide me. Essay writing service

Unique Submission said...


When it comes to your academic dreams and grades we try to give our best by supporting you in completing your college assignments.
Our administrative experts work dedicatedly and passionately to provide top quality essay writing help to the students. Meticulous paper structures,
subject matter relevance, free from grammatical errors are main characteristics that our highly experienced and talented writers endeavor for.
Still drowning in the worry to complete your college assignments?

Assignment helpers Online

Libin John said...

We at Indias Fastest News We try To provide the true side of the news, facts which are happening all over the globe

IFN Website

Libin John said...

If you want to stay updates with the latest technology related news we write different articles which includes Full Comparison | Specifications |Reviews. Do Check The website

For All latest Technology related news

NISHA said...



Most of the students are fascinated with opting Law as a career.
A good academic record leads to a good placement also.
Unique Submission law assignment writing help services are here to take off the burden of multiple
assignment writing topics from your shoulders.
Here our law subject expert writers will ensure to get you peerless outcomes with their
law assignments help on the comprehensive writing academic field.

Law assignment writing help

bonni bennette said...

Quite interesting post you made. It’s good shared information and the article is pretty helpful. I like the write-up’s structure and flow, as it kept me engaged all this time.There is so much to learn from this piece. You are a great help and I would surely try to follow all the learning.
MatlabAssignment.com Matlab Assignment Help ,CDR report writing services,Career episode writing services, Mechanical Engineering Assignment Help,matlab Assignment Help .

customerservicehelpnumber said...

Your blog is really awesome and I really enjoyed it. Please post some other blogs. I have read out your blog post but I am here for the performance related to HP printers. I have gone through some untouched facts that are helpful to notice the problem in the concerned part. The main attraction point of view in this content is that it brings forward some facts that are worthy to trace down the burning problem in HP printers. They do not leave any stone unturned to get rid of complicated issues. But, this instruction is beneficial for those who know the fundamentals of the computer and hardware. If you feel helpless to figure out the cause of the problem, then you can take the help of the HP Printer Support team. They will help you a lot to take the full advantage of your hardly earned machine to fetch output. Visit our given links for information of HP Support:
HP Printer Customer Service,
HP Printer Tech Support,
HP Technical Support,
How do I troubleshoot my HP printer?,
Does HP have a customer service number?,
Where is the HP Support Assistant?
We are happy to help, so always feel free to contact us.
Thank You.

Veronica Kate said...

Extremely well written paper, however a few more points can be added to make it all the more resourceful. Visit livewebtutors and make most of the valuable Vancouver Referencing Generator as offered by the best in the business. Feel free to get in touch at any point of the day.

Getassignmenthelp said...

Are you facing problem while drafting your academic paper then i will suggest please click here
Assignment Help
Law Assignment Help
Java Assignment Help
Mathematics Assignment Help
Finance Assignment Help
Essay Help
Homework Assignment Help
Account Assignment Help

Chris Lucas said...

You might feel like asking, “Can someone help me with my assignment” due to a lack of clear concept. Our assignment helpers are highly experienced and have a vast knowledge. Thus, they can easily prepare a highly informative assignment for you. With their help, you can also clear out all your concepts.

Assignment help | Online assignment help | Essay help online