• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Groovy: belongsTo

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a zygote groovy programmer, and would like to know how to implement the following in groovy:

1- - Updating a Listing should not update the seller's information.
2- - Updating a seller's information should not modify any properties of that seller's listings



In order to implement aforementioned requirements I looked into groovy docs and found out that belongsTo will serve my purpose. However, I am not sure if belongsTo makes sense in the Listing class because it enforces the "Composition" relationship with Customer. Am I on the right track??

Thanks, any help will be highly appreciated.





 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure why you think that belongsTo has any impact on your 2 requirements. All you're doing with belongsTo and hasMany is defining the relationship and possibly, the cascading effect of those relationships. You've also obviously not tried this or written any tests otherwise, you would have found out that your syntax is wrong. belongsTo and hasMany are either lists or maps. Not closures.
 
Oscar Hansen
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My apologies, I made mistake while copying the code snippet. Yes you were right about the belongsTo and hasMany, this part is clear to me now thanks for that. The only part that I am still trying to figure out is where to look to implement the requirements. Can I get some pointers or references??
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're going to have to give some more details. For example, when you say:

1- - Updating a Listing should not update the seller's information.

If you don't change the seller's info, it doesn't change. Are you experiencing something different?

If I did the following:



Nothing about any of listings' sellers changes.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic