-
Notifications
You must be signed in to change notification settings - Fork 562
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
Exception thrown when attempting to fetch null relationship on lazy loaded DBRef [DATAREST-359] #741
Comments
Aaron Loes commented using spring-data-mongo version 1.5.1.RELEASE and spring-data-rest-webmvc version 2.1.1.RELEASE |
Sri commented same issue is already raised - DATAREST-310. However good job on adding details |
Gary Frankel commented Dont know whether this needs to be a different request..... Using Spring Data MongoDB (1.6.1 or 1.6.2) and spring-boot-starter-web 1.2.1 and spring-data-rest-webmvc 2.2.1, I see a very similar issue. Ran into because I'm working on a different database that also has lazy loading and wanted to see what the Mongo implementation does. Yes, the ID is initialized on the proxy... BUT as we go all the way through to creating a return value, eventually, we get the JSON exception shown below.... I was wrong on my initial comment - not due to the Lazy Loader not being called... Now, seems like this would have come up before - I did try setting BUT maybe the code is supposed to get rid of the Proxy before calling all the writers/serializers so that it never hits this serializer for a proxy class ?? Not surprisingly, the same thing happens when I do a Projection that causes the Address to be embedded into the feed for /people. "Could not write content: No serializer found for class org.springframework.data.mongodb.core.convert.DefaultDbRefResolver$LazyLoadingInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) ) Daemon Thread [http-nio-8080-exec-1] (Suspended (exception JsonMappingException)) |
Caleb Cushing commented
I've seen this same issue with Hibernate, I was about to report it. |
Caleb Cushing commented this tarball contains a repo showing this same error with hibernate. There is uncommitted change from lazy to eager that fixes the problem.
|
Oliver Drotbohm commented I just ran
Generally speaking: would you guys mind trying more recent versions of Spring Data REST than the ones? Spring Boot 1.2.5 is on Evans SR1 (Dec 2014), which is pretty dated and the subsequent versions (Evans current service release is SR3 - Jul 2015, Fowler SR2 (Jul 2015), Gosling GA (Sep 2015) |
Caleb Cushing commented
yeah tests don't fail, but did you remove the "uncommitted change to eager"? a ```
|
Caleb Cushing commented Having trouble upgrading, I added this to <properties> in the pom
but now I get this error
|
Caleb Cushing commented I removed the patch for eager, as mentioned I've been unsuccessful in upgrading, the instructrions in http://spring.io/blog/2015/09/01/spring-data-release-train-gosling-goes-ga seem incomplete.
|
Oliver Drotbohm commented The upgrade to Gosling also requires an upgrade of Jackson to 2.5 or better (I just added that to the blog post). Alternatively just switch to Spring Boot 1.3 M5 as it ships all libraries in the required versions |
Caleb Cushing commented all that was updated in the current tarball was <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.M5</version>
</parent>
also this new exception doesn't appear to be getting logged |
Oliver Drotbohm commented So let's please take a step back. I am a bit lost in all the samples you post. Would you mind just providing a sample that reproduces the error with a simple |
Caleb Cushing commented attaching sample with test, there are 2 branches in this tarball, one uses Spring Boot 1.2.5, the other 1.3.0.M5. both fail |
Petar Tahchiev commented I can confirm the same error happens with Hopper-SNAPSHOT :( |
Petar Tahchiev commented I'm sorry for the noise - I have upgraded to Hibernate 5.2 with jackson-datatype-hibernate5 and that's why the error came. When I downgrade to hibernate 5.1 and jackson-datatype-hibernate5 it all works fine |
Oliver Drotbohm commented I am puzzled. Did you intend to comment another ticket? This one is about MongoDB, not JPA |
Oliver Drotbohm commented I can see the sample working when I upgrade to Spring Boot 1.3.7 and add the Hibernate Jackson integration |
Petar Tahchiev commented It happens with JPA too. I saw this one: https://jira.spring.io/browse/DATAJPA-630 and there it was recommended to open it in DATAREST. I have commented on the jackson-datatype-hibernate: |
Oliver Drotbohm commented To be completely honest I don't care much about issues introduced in Hibernate 5.2. Actually, the release breaking so many things so horribly is the reason that Boot 1.4 ships 5.0 out of the box. That said, — again — the sample provided works on Boot 1.3.7 (Gosling SR4). Whenever you customize persistence provider versions beyond that, be prepared to run into issues. Inclined to close this as fixed against Gosling SR4, as it's the version I can see the previously failing example work on |
Casey Link commented I'm experiencing this issue with spring data jpa, specifically this issue when fetching a relationship like so:
This ticket isn't related to JPA as you said, but I am hesitant to open another issue, if one exists please point me in that direction. I'm using:
A related question, I need to specify my hibernate version explicitly in order to pin some other non-spring packages. I want to use the latest supported/recommended hibernate version from spring-data. Where do I go to find out what version this is? Looking at the compile dependencies section of spring-data-jpa it looks like hibernate 5.2.4 is supported. edit: updated to latest versions of hopper release train and boot, same results |
Aaron Loes opened DATAREST-359 and commented
This appears to be an issue with using SD Rest with SD MongoDB and lazy DBRefs.
Given my Farmer class:
And when creating an instance of a farmer:
All is well until i try to get the farmers spouse:
and this is the exception thrown:
It was expected a 404 would have been returned. This does not happen when we are not lazy loading relationships
Attachments:
4 votes, 9 watchers
The text was updated successfully, but these errors were encountered: