Grails - composite key class usage
I've recently changed some mapping in my app and now it looks like this.
Scenario - many-to-many - Subscription
Composite key cl开发者_如何学运维ass -> ScenarioSubscription
class ScenarioSubscription {
int id
Scenario scenario
Subscription subscription}
Works fine for me. But Since I didn't have this setup before I've used things like:
scenario.subscriptions.clear()
And I don't want to change all of that code. Is there some way I can still get this functionality with the composite class?
I tried doing like:
def subscriptions(){
def subs = new SortedSet();
for(ScenarioSubscription s : scenarioSubscriptions){
subs.add(s.subscription);
}
return subs;
}
in Scenario.groovy; But that only works when reading of course, I can't remove items etc...
精彩评论