Skip to content
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

ETag getVersionInformation fails with proxied Entities for projections [DATAREST-581] #955

Closed
spring-projects-issues opened this issue Jun 17, 2015 · 11 comments
Assignees
Labels
type: regression

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jun 17, 2015

Tim te Beek opened DATAREST-581 and commented

See the reference GitHub project.

I've got an @Entity with a @Version'ed field, a @Projection, and a Repository. When I try to GET the projection of a single entry, I get a 500 Internal server error, because of a failed assertion in BasicPersistentEntity line 394, as called from Etag line 191:

Assert.isTrue(getType().isInstance(bean), "Target bean is not of type of the persistent entity!");

The argument bean here is of type $Proxy90 / JdkDynamicAopProxy, not Book.

The projection only works again when the @Version annotation is removed. This is since Fowler, as I had no such issues with Evans


Affects: 2.3 GA (Fowler)

Reference URL: https://github.com/timtebeek/etag-projection

Backported to: 2.3.1 (Fowler SR1)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 17, 2015

Oliver Drotbohm commented

Do you have a stack trace handy? Actually all request preparing code should see the actual domain object, not a projection but I'd have a look

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 18, 2015

Tim te Beek commented

There's no stacktrace that shows up in the app-server log, just a 500 response to the client.

It's a simple IllegalArgumentException that's thrown with the message:
"Target bean is not of type of the persistent entity!"
Through:

  • org.springframework.util.Assert line 68
  • org.springframework.data.mapping.model.BasicPersistentEntity line 394
  • org.springframework.data.rest.webmvc.support.ETag line 191

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 18, 2015

Oliver Drotbohm commented

Okay, a reproducing sample project maybe?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 18, 2015

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 18, 2015

Oliver Drotbohm commented

Doh! Stupid me… I'll have a look

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 19, 2015

Tim te Beek commented

Saw some linked commits already; Thanks for looking into this!
Anything I can do / test / update past this point, or is testing already covered by the new createsEtagForProjectedEntityCorrectly now?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 19, 2015

Oliver Drotbohm commented

I just wanted to make sure the snapshot builds for both branches build and had to go down a rabbit hole of other issues. Both 2.4 and 2.3.1 snapshots should be available for testing

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 14, 2015

Tim te Beek commented

Issue can be closed: Was fixed in spring-data-rest 2.3.1. Thanks a lot!

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Nov 9, 2015

Gennadii Kurbatov commented

Problem again resume, but for PUT method:

java.lang.IllegalArgumentException: Target bean is not of type of the persistent entity!
	at org.springframework.util.Assert.isTrue(Assert.java:68) ~[spring-core-4.2.2.RELEASE.jar:4.2.2.RELEASE]
	at org.springframework.data.mapping.model.BasicPersistentEntity.getPropertyAccessor(BasicPersistentEntity.java:394) ~[spring-data-commons-1.11.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.support.ETag.getVersionInformation(ETag.java:191) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.support.ETag.from(ETag.java:76) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.prepareHeaders(AbstractRepositoryRestController.java:171) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.prepareHeaders(AbstractRepositoryRestController.java:157) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.RepositoryEntityController.saveAndReturn(RepositoryEntityController.java:495) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Nov 10, 2015

Gennadii Kurbatov commented

Problem solved. We are use Backbone on frontend and for getting model apply projection. Therefore before save model must be

this.model.unset("projection");
this.form.model.save(...);

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 3, 2016

Andrew Walters commented

Raised DATAREST-761 as a similar issue or possible regression

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

No branches or pull requests

2 participants