New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Result Class cannot subclass objects with same field names #384
Comments
User result class has a code smell (field name that is inaccessible, and hence undefined what should happen to it in terms of population from the query result processing). Test doesn't show that, even with the PR (to avoid the exception), the result object superclass field value is NOT populated when extracting the value from the JDBC result set. Maybe it should be, maybe not. |
While I agree that this is code smell in the ResultClass, is it DN's responsibility to prevent that? I would say that since the subclass is the class being presented as the ResultClass, its setter should be the one called and not that of the parent class. That would mean that the parenet class's field would remain undefined. Agreed that the test (with the PR) does not show this explicitly, however implicitly I believe it does. Are you inclined to accept this PR if I update the test to be more explicit? (Would also update to show that mismatched names will continue to be rejected). Or are shadowed field names considered to be non-DN compliant? |
My comments are to CLARIFY what the "problem" is, not to say that a PR is not to be applied. The PR is simply to avoid the exception and ignore the setting of shadowed fields ... no issue with the PR for me there. The fact that your situation is for multiple fields "name" (nothing to do with casing of the name) could imply that ALL fields in the result object should be set. This is a wider question than the problem you are wanting to solve presumably; the JDO spec doesn't define AFAIK what happens with shadowed fields. Either way I won't be including any support for setting shadowed fields in 5.x, just catering for the exception as your PR does |
Fixed with commit for #385 |
Bug:
When specifying a ResultClass in a native SQL query without any CandidateClass specified, the result class cannot subclass another class with the same fieldname.
DN throws an exception:
however, the statement is not accurate. In fact, if a parent class has a field of the same name, the exception is thrown. This can be seen since
ResultClassROF.java:499
normalizes the fieldnames (uppercase) in a map to determine if there are duplicate fieldnames:Steps to reproduce:
where PersonInfo is a subclass of another class with a "name" field.
Example:
See SimpleTest.java at https://github.com/benze/test-jdo/tree/inherited_field_result_class_error
Version:
DataNucleus 5.2.8
The text was updated successfully, but these errors were encountered: