File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Groovy and the fly likes Groovy: belongsTo Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Other Languages » Groovy
Reply 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
Sheriff

Joined: Jul 11, 2001
Posts: 15040

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.


My Blog | DZone Articles
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
Sheriff

Joined: Jul 11, 2001
Posts: 15040

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.
 
 
subject: Groovy: belongsTo
 
Threads others viewed
Dynamically populating an inputTextArea with the values being selected from the UI
Need to know what kind of values and how to pass them to Map<String String>
struts iterate tag
Variable in properties file.
Why Constructor Chaining ?
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com