apache / apache/grails-core

groovy.lang.MissingPropertyException on reading property from a domain sub classs

Open
#14,550 0 comments 0 reactions 0 assignees View on GitHub
relates-to: gorm
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.