开发者

Grails - composite key class usage

开发者 https://www.devze.com 2023-04-11 15:26 出处:网络
I\'ve recently changed some mapping in my app and now it looks like this. Scenario - many-to-many - Subscription

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...

0

精彩评论

暂无评论...
验证码 换一张
取 消