开发者

Inheritance in Groovy -Base class table lists entries of sub class

I have class Contract which extends Base class Rule . i have different CRUD for Rule and Contract. my b开发者_高级运维ase class has got 6 fields and derived class got 3 specified fields. when i am listing the Rules created, it also displays Contract which is saved in the table. if i am listing rule it should list only Rules. how can i do that? what is the Thing that i need to take care when dealing with groovy inheritance?


This is logically correct as per the hierarchy you have, as every contract is rule also. IMO, there could be two options :

  • Create another subclass of Rule that would only mean Rule not the contract, as you separate CRUD for them too.
  • Add a property (may be RuleType Enum) to both Rule and Contract, to differentiate amogst them and then use Rule.findAllByRuleType(RuleType.OnlyRule)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜