Skip to content

Build time return NullPointerException on get/set prefix method name in entity class #102

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

Closed
chanhengseang3 opened this issue Apr 6, 2019 · 3 comments

Comments

@chanhengseang3
Copy link
Contributor

Updating from 0.3.13 version to 0.3.17 returns NullPointerException . When class GraphQLJpaSchemaBuilder tries to search for @Transient , class IntrospectionUtils tries to read all the methods that have name start with get or set. Whenever the Entity class contains methods that have prefix get or set then it will try to find that properties. If the properties are not found then IntrospectionUtils will return NullPointerException.

There are cases that method names that start with get or set has nothing to do with properties. For example, with method getHello, it will try to find the property name hello. But there is no hello property in this entity. getHello method is not intended for get hello properties.

We tried to have Beans @Transient annotated on the method, but we still got NullException error.

@igdianov
Copy link
Collaborator

igdianov commented Apr 7, 2019

@chanhengseang3 Thank you for reporting the issue. Could post an example entity class that causes the problem to help me build the test case. Thank you!

@goldbach00009
Copy link

I have the same issue; with 0.3.10-SNAPSHOT it works fine, with 0.3.18-SNAPSHOT (same classes / same JPA model) I get two different issues related to @transient. One of the issues can be traced somewhere around in this method

@SuppressWarnings( { "rawtypes" } )
private GraphQLFieldDefinition getJavaFieldDefinition(PropertyDescriptor propertyDescriptor) {
	GraphQLOutputType type = getGraphQLTypeFromJavaType(propertyDescriptor.getPropertyType());
    DataFetcher dataFetcher = PropertyDataFetcher.fetching(propertyDescriptor.getName());

    return GraphQLFieldDefinition.newFieldDefinition()
            .name(propertyDescriptor.getName())
            .description(getSchemaDescription(propertyDescriptor.getPropertyType()))
            .type(type)            //HERE! type is null so build() fails with 'Type can't be null'
            .dataFetcher(dataFetcher)
            .build();
}

type is null (and the stacktrace that follows remarks that). With a conditional breakpoint, I found that the problem refers to the following method of one of my entities:

   @Transient @JsonIgnore
public List<InfoService> getAll() {
....
}

The method above is where propertyDescriptor points then the conditional breakpoint is triggered.

I swapped the old version back; let me know if you need more info (and which type of info).

igdianov pushed a commit that referenced this issue Apr 12, 2019
…#106)

* #102 fix NullPointerException when searching for Transient annotation properties

* #102 add setSth() method to test schema build

* #102 Change test
@igdianov
Copy link
Collaborator

igdianov commented Apr 12, 2019

Fixed in 0.3.18 via fb45d23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants