maaz
maaz

Reputation: 3666

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 base 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?

Upvotes: 0

Views: 456

Answers (1)

Amit Jain
Amit Jain

Reputation: 1382

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)

Upvotes: 1

Related Questions