Skip to content

NullPointerException for stored procedure call using @Query #2834

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
Swierkowski opened this issue Mar 2, 2023 · 1 comment
Closed

NullPointerException for stored procedure call using @Query #2834

Swierkowski opened this issue Mar 2, 2023 · 1 comment
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@Swierkowski
Copy link

Swierkowski commented Mar 2, 2023

I am migrating a project form spring-boot 2.7.5 to 3.0.3 (spring-data-jpa:3.0.2).

There is the below working stored procedure call:

public interface PaymentMessageStatusRepository extends JpaRepository<PaymentMessage, Integer> {

@Query(value = "CALL set_swf(:sourceId, :description)", nativeQuery = true)
    void saveMessageHistory(Integer sourceId, String description);

}

It has stopped working for spring-data-jpa:3.0.2 and the below NullPointerException is thrown:

Caused by: java.lang.NullPointerException: Cannot invoke "String.contains(java.lang.CharSequence)" because "variable" is null
                at org.springframework.data.jpa.repository.query.QueryUtils.createCountQueryFor(QueryUtils.java:620) ~[spring-data-jpa-3.0.2.jar:3.0.2]
                at org.springframework.data.jpa.repository.query.DefaultQueryEnhancer.createCountQueryFor(DefaultQueryEnhancer.java:49) ~[spring-data-jpa-3.0.2.jar:3.0.2]
                at org.springframework.data.jpa.repository.query.StringQuery.deriveCountQuery(StringQuery.java:111) ~[spring-data-jpa-3.0.2.jar:3.0.2]
                at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.<init>(AbstractStringBasedJpaQuery.java:82) ~[spring-data-jpa-3.0.2.jar:3.0.2]
                at org.springframework.data.jpa.repository.query.NativeJpaQuery.<init>(NativeJpaQuery.java:58) ~[spring-data-jpa-3.0.2.jar:3.0.2]
                at org.springframework.data.jpa.repository.query.JpaQueryFactory.fromMethodWithQueryString(JpaQueryFactory.java:53) ~[spring-data-jpa-3.0.2.jar:3.0.2]
                at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:170) ~[spring-data-jpa-3.0.2.jar:3.0.2]
                at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:252) ~[spring-data-jpa-3.0.2.jar:3.0.2]
                at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:95) ~[spring-data-jpa-3.0.2.jar:3.0.2]
                at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.lookupQuery(QueryExecutorMethodInterceptor.java:111) ~[spring-data-commons-3.0.2.jar:3.0.2]
                ... 120 common frames omitted

It is the same for other stored procedure calls in this project.

The workaround is adding countQuery inside the @query, but I believe that throwing NullPointerException was not intentional in such case.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 2, 2023
@gregturn gregturn self-assigned this Mar 2, 2023
@gregturn gregturn added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 2, 2023
@gregturn
Copy link
Contributor

gregturn commented Mar 2, 2023

Looks like a duplicate of #2812, which has been patched. You can either grab the snapshot of wait for our patch release scheduled for tomorrow.

@gregturn gregturn closed this as completed Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants