groovy.lang.MissingPropertyException on reading property from a domain sub classs
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
I have the following domain classes in my test app
-----
class PricePlan {
String id
double price
static mapping = {
id type: 'string', generator: 'assigned'
discriminator column: 'purchase_type'
}
}
-----
class RecurringPricePlan extends PricePlan {
int durationInMonths
static mapping = {
discriminator 'Subscription'
}
}
-------
class SubscriptionPlan {
PricePlan pricePlan
static constraints = {
pricePlan nullable: true
}
int getDurationInMonths() {
pricePlan.durationInMonths
}
}
-----
Steps to reproduce
1. save RecurringPricePlan
2. Assign the saved RecurringPricePlan to new SubscriptionPlan
3. save SubscriptionPlan
4. Find SubscriptionPlan by id
5. invoke subscriptionPlan.getDurationInMonths()
6. getting following exception
groovy.lang.MissingPropertyException: No such property: durationInMonths for class: RecurringPricePlan
Possible solutions: durationInMonths
Can you please let me know why i am seeing this error?
Contributor guide
Research direction
Start with the PricePlan, RecurringPricePlan, and SubscriptionPlan domain classes shown in the issue, then reproduce the listed save, reload, and getDurationInMonths steps. Investigate why durationInMonths is unavailable after retrieving the SubscriptionPlan; done means the cause is established and the reported exception is resolved or its expected behavior is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100