Skip to content

fix: support uppercase attribute names introspection #173

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

Merged
merged 45 commits into from
Sep 8, 2019

Conversation

igdianov
Copy link
Collaborator

@igdianov igdianov commented Aug 28, 2019

Fixes #172
Fixes #174

@igdianov igdianov self-assigned this Aug 28, 2019
@igdianov igdianov added the bug label Aug 28, 2019
@codecov
Copy link

codecov bot commented Aug 28, 2019

Codecov Report

Merging #173 into master will increase coverage by 2.11%.
The diff coverage is 75.18%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #173      +/-   ##
============================================
+ Coverage     68.83%   70.94%   +2.11%     
- Complexity      516      874     +358     
============================================
  Files            33       51      +18     
  Lines          2663     3848    +1185     
  Branches        436      661     +225     
============================================
+ Hits           1833     2730     +897     
- Misses          664      839     +175     
- Partials        166      279     +113
Impacted Files Coverage Δ Complexity Δ
...jpa/query/schema/impl/GraphQLJpaSchemaBuilder.java 91.2% <100%> (-0.05%) 118 <7> (-1)
...ql/jpa/query/introspection/PropertyDescriptor.java 61.4% <61.4%> (ø) 28 <28> (?)
...es/graphql/jpa/query/introspection/Descriptor.java 61.53% <61.53%> (ø) 11 <11> (?)
...raphql/jpa/query/introspection/ReflectionUtil.java 65.97% <65.97%> (ø) 76 <76> (?)
...phql/jpa/query/schema/impl/EntityIntrospector.java 70.07% <70.07%> (ø) 8 <8> (?)
...hql/jpa/query/introspection/ClassIntrospector.java 72.5% <72.5%> (ø) 3 <3> (?)
...s/graphql/jpa/query/introspection/Annotations.java 74.35% <74.35%> (ø) 11 <11> (?)
...jpa/query/introspection/ConstructorDescriptor.java 75% <75%> (ø) 10 <10> (?)
...ures/graphql/jpa/query/introspection/BeanUtil.java 76% <76%> (ø) 21 <21> (?)
.../jpa/query/introspection/AnnotationDescriptor.java 79.16% <79.16%> (ø) 12 <12> (?)
... and 30 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6552cb8...5a51ccf. Read the comment docs.

@igdianov
Copy link
Collaborator Author

@pierrefoyard Please, check the fix. Feel free to add your unit tests..

Copy link

@pierrefoyard pierrefoyard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great!
many thanks for this quick fix!

@igdianov
Copy link
Collaborator Author

@anotender @SinaiNIN I had refactored IntrospectionUtils to use ManagedType to be able to resolve annotations for transient and persistent properties and getter methods within class hierarchy.

Give it a spin and let me know if there are any problems.

@igdianov igdianov force-pushed the igdianov-fix-uppercase-properties branch from f9f4581 to da0d06b Compare August 31, 2019 22:07
@anotender
Copy link
Contributor

anotender commented Sep 2, 2019

@igdianov I've checked new changes against the model in our app but the issue with protected getter and field present in the metamodel still exists unfortunately. We use org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor do generate the metamodel and it generates attribute from the protected getter while the Introspector.getBeanInfo(...) finds only public ones. It'll be greate if we can include non-public fields into introspection.

@igdianov
Copy link
Collaborator Author

igdianov commented Sep 3, 2019

@anotender I have added introspection support for protected getter methods (d88953c). Let me know if it works for you.

@igdianov
Copy link
Collaborator Author

igdianov commented Sep 5, 2019

@anotender I have replaced Java's built-in bean introspection with custom implementation (10de6d6) that can be customized to scan non public properties. I did not want to go that route, but I see no other choice because I don't want to bring any external dependencies.

Your test case (7fd94dd) now passes. Let me know if there is anything else we need to cover. I will also need to cover tests for custom introspection implementation. It may be good in the long run to be able to add support for complex types in GraphQL mapping.

@anotender
Copy link
Contributor

anotender commented Sep 5, 2019

@igdianov many thanks! I've checked with our entity model and it looks like it works as it should for us. You're right about the test coverage of the code introduced so we need to add tests for it in the near future.

@igdianov igdianov force-pushed the igdianov-fix-uppercase-properties branch from 41bae6c to f2790c4 Compare September 6, 2019 00:15
@igdianov igdianov merged commit 798b30d into master Sep 8, 2019
@igdianov igdianov deleted the igdianov-fix-uppercase-properties branch September 8, 2019 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NoSuchFieldException: Property not found when declare private access modifier on getter method Fails on bean properties starting with upper case
3 participants