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
NullPointerException in AbstractStringBasedJpaQuery.isJpaManaged() [DATAJPA-929] #1283
Comments
Oliver Drotbohm commented Thanks for filing this, Ondřej. This looks very much related to (but not caused by) DATAJPA-904. Generally speaking, |
Oliver Drotbohm commented Nevermind, I already filed a ticket here |
Chris Cranford commented -Is this happening because the user is querying the Envers audit table through spring-data-jpa?- Please disregard, I was looking at master rather than the explicit release related to this ticket |
Maximos Sapranidis commented I am in the process of updating to Spring Boot 1.4 and just bumped into the exact same issue. |
Chris Cranford commented
|
Oliver Drotbohm commented The fix for that has already been released in Ingalls M1, so you should be able to upgrade to that one by setting the |
Maximos Sapranidis commented Unfortunately both suggested solutions did not work for me, I guess I will have to wait for the official update :( |
Oliver Drotbohm commented What do you exactly mean with "didn't work for me"? |
Maximos Sapranidis commented After I specify the hibernate version I manage to make most of my tests pass but for some integration tests I am getting from the repository the following exception: java.lang.NullPointerException
at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.isJpaManaged(AbstractStringBasedJpaQuery.java:155)
at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.createJpaQuery(AbstractStringBasedJpaQuery.java:141)
at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.doCreateQuery(AbstractStringBasedJpaQuery.java:80) The specific repository is handling one part of a many to many relation between users and accounts. Another thing I have noticed, is that when running a test method then the test passes as expected, but when running the whole class then the test fails. Hope this gave some more insights, Cheers |
Oliver Drotbohm commented While the issue is in fact caused by Hibernate the Spring Data JPA version I suggested to update to has a workaround for that bug. So if you follow the advice above you should be abe to use a version, that has this fixed |
Maximos Sapranidis commented The issue is indeed resolved using the latest release but now I just bumped into another issue, we are using Optional return type and JPQL projection to create an object (not an Entity type) org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.util.Optional<?>] to type [com.cookies.domain.dto.AuthenticationPrincipal] The Query is : @Repository
public interface UserPrincipalRepository extends CrudRepository<UserAccountPair, String> {
@Query(value = "SELECT " +
"new xxx.AuthenticationPrincipal(u.id, u.email, u.password, u.enabled) " +
"FROM ApiUser u "
+ "WHERE LOWER(u.email) = LOWER(?1)")
Optional<AuthenticationPrincipal> findUserForAuthentication(String string);
} If I remove the Optional the query works as expected, but this was working as is in the previous versions. |
Oliver Drotbohm commented Would you mind opening another ticket for this, please? |
Maximos Sapranidis commented Yes, definitely, here you go DATAJPA-951 thanks for the quick response |
Ondřej Havelka opened DATAJPA-929 and commented
Hi,
I'm using SpringData JPA Hopper-SR1 and I want to upgrade to Hopper-SR2 but I'm facing NullPointer exception in AbstractStringBasedJpaQuery.isJpaManaged() which in newly introduced in Hopper-SR2 (with Hopper-SR1 everything works fine)
I'm using Envers
I have entity DonwloadItem which has correspoding table "download_item"
but in db there is also envers auditing table "download_item_AUD" which doesn't have corresponding Java Type and thats the problem
In method isJpaManaged() is called managedType.getJavaType() that returns null for ManagedType that contains DownloadItem_aud entity
Stacktrace:
Affects: 1.10.2 (Hopper SR2)
Issue Links:
Referenced from: commits 0fae610, c4b9a03
Backported to: 1.10.3 (Hopper SR3)
The text was updated successfully, but these errors were encountered: