aspose file tools*
The moose likes Groovy and the fly likes Groovy: belongsTo Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Groovy: belongsTo" Watch "Groovy: belongsTo" New topic
Author

Groovy: belongsTo

Oscar Hansen
Greenhorn

Joined: Jul 09, 2008
Posts: 10
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.





Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
Oscar Hansen
Greenhorn

Joined: Jul 09, 2008
Posts: 10
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Groovy: belongsTo