Can Spring Data REST’s QueryDSL integration be used to perform more complex queries?

I think you should be able to get this to work using the following customization: bindings.bind(user.dateOfBirth).all((path, value) -> { Iterator<? extends LocalDate> it = value.iterator(); return path.between(it.next(), it.next()); }); The key here is to use ?dateOfBirth=…&dateOfBirth= (use the property twice) and the ….all(…) binding which will give you access to all values provided. Make sure … Read more

While using Spring Data Rest after migrating an app to Spring Boot, I have observed that entity properties with @Id are no longer marshalled to JSON

By default Spring Data Rest does not spit out IDs. However you can selectively enable it through exposeIdsFor(..) method. You could do this in configuration, something like this @Configuration public static class RepositoryConfig extends RepositoryRestMvcConfiguration { @Override protected void configureRepositoryRestConfiguration( RepositoryRestConfiguration config) { config.exposeIdsFor(Class1.class, Class2.class); } }

Enable HAL serialization in Spring Boot for custom controller method

There’s a lot of aspects here: I doubt that the collection resource at /transactions really returns an individual transaction as you described. Those representations are returned for item resources. If TransactionRepository already is a PageableAndSortingRepository the collection resource can be tweaked by expanding the URI template exposed in the API root for the link named … Read more

Disable Hypertext Application Language (HAL) in JSON?

(Hyper)media types The default settings for Spring Data REST use HAL as the default hypermedia representation format, so the server will return the following for the given Accept headers: No header -> application/hal+json -> HAL application/hal+json -> application/hal+json -> HAL application/json -> application/json -> HAL (this is what the default configures) application/x-spring-data-verbose+json -> application/x-spring-data-verbose+json -> … Read more

How to use Spring managed Hibernate interceptors in Spring Boot?

There’s not a particularly easy way to add a Hibernate interceptor that is also a Spring Bean but you can easily add an interceptor if it’s managed entirely by Hibernate. To do that add the following to your application.properties: spring.jpa.properties.hibernate.ejb.interceptor=my.package.MyInterceptorClassName If you need the Interceptor to also be a bean you can create your own … Read more

POSTing a @OneToMany sub-resource association in Spring Data REST

Assuming you already have discovered the post URI and thus the URI of the association resource (considered to be $association_uri in the following), it generally takes these steps: Discover the collection resource managing comments: curl -X GET http://localhost:8080 200 OK { _links : { comments : { href : “…” }, posts : { href … Read more

Spring Data Rest and Cors

Indeed, before Spring Data REST 2.6 (Ingalls) only HandlerMapping instances created by Spring MVC WebMvcConfigurationSupport and controllers annotated with @CrossOrigin were CORS aware. But now that DATAREST-573 has been fixed, RepositoryRestConfiguration now exposes a getCorsRegistry() for global setup and @CrossOrigin annotations on repositories are also recognized so this is the recommended approach. See https://stackoverflow.com/a/42403956/1092077 answer … Read more