0

I am working on a project that does not allow for Hibernate due to the license. We are working with spring-boot-starter-parent 1.5.10.RELEASE, Spring Data JPA, and Spring Data REST with HATEOAS. Specifically, the following:

  • spring-data-jpa:1.11.10.RELEASE
  • spring-data-rest-core:2.6.10.RELEASE
  • spring-data-rest-webmvc:2.6.10.RELEASE
  • spring-hateoas:0.23.0.RELEASE
  • openjpa-all:2.4.2
  • h2:1.4.194 (for dev and automated testing)
  • postgresql:42.1.4 (for production)

We have excluded the hibernate dependencies.

The following behavior is observed on PATCH and DELETE:

PATCH

ERROR o.s.d.r.w.RepositoryRestExceptionHandler - Cannot cast org.apache.openjpa.util.StringId to java.lang.String

DELETE

ERROR! org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.apache.openjpa.util.StringId] to type [java.lang.String]

Does anyone know how to make the Spring/OpenJpa combination happy?

We have an integration requirement that forces us to use String as the Correlation id. We are hoping to leverage the out of the box features with paging, sorting, etc. A basic entity field definition looks like this:

@Id
@Expose
@Column(name = "operator_id")
private String id;

GET and POST behavior are working fine.

Any assistance is much appreciated!

Josh Hays
  • 51
  • 1
  • 6
  • I found an answer to DELETE using a custom converter, but am still wrestling with PATCH. – Josh Hays Mar 12 '18 at 22:14
  • This seems to be similar to this issue: https://stackoverflow.com/questions/43710517/error-while-updating-data-using-springboot-data-rest-and-openjpa I am actively trying to get to Spring 2.x so would prefer to not go back to older versions if possible. – Josh Hays Mar 14 '18 at 13:33
  • I debugged the code down to this class: `org.springframework.data.rest.webmvc.config.PersistentEntityResourceHandlerMethodArgumentResolver` The exception is thrown from this method: resolveArgument. It seems my custom OpenJpaStringIdConverter is not available here like it is for the DELETE scenario. My current workaround is to just disable PATCH and PUT at the security layer and only allow POST. POST is working for create or update as long as the id to update is passed in the request. I would still like to know the answer to PATCH and PUT for this if anyone has insight. – Josh Hays Mar 14 '18 at 13:37

0 Answers0