spring-data-rest

Handle spring-data-rest application events within the transaction

帅比萌擦擦* 提交于 2019-12-17 18:43:30
问题 I need to publish notification events to external systems over JMS, when data is updated. Id like this to be done within the same transaction as the objects are committed to the database to ensure integrity. The ApplicationLifecycle events that spring-data-rest emits seemed like the logical place to implement this logic. @org.springframework.transaction.annotation.Transactional public class TestEventListener extends AbstractRepositoryEventListener<Object> { private static final Logger LOG =

Spring Data Rest Without HATEOAS

别等时光非礼了梦想. 提交于 2019-12-17 18:36:08
问题 I really like all the boilerplate code Spring Data Rest writes for you, but I'd rather have just a 'regular?' REST server without all the HATEOAS stuff. The main reason is that I use Dojo Toolkit on the client side, and all of its widgets and stores are set up such that the json returned is just a straight array of items, without all the links and things like that. Does anyone know how to configure this with java config so that I get all the mvc code written for me, but without all the

Using @Version in spring-data project

廉价感情. 提交于 2019-12-17 18:13:37
问题 I've been working on a RESTful webservice with spring-data. A few days ago a special spring-data jpa REST framework was released. Now I noticed the ability to use @Version with this framework. Is this version generated by itself or do you need to do this manually? And is it possible to use @Version on it's own? (So that I don't have to change anything to my existing repositories/domain etc..) And do I need to do some extra configuration to make use of @Version? 回答1: It's been a while since I

How to disable the default exposure of Spring Data REST repositories?

こ雲淡風輕ζ 提交于 2019-12-17 17:52:25
问题 I have a project that uses spring-data-rest, and has a dependency project that only uses Spring Data. Both projects have spring data repositories and use @EnableJpaRepositories to implement their repository interfaces, but I only want to export the repositories in the parent project. Here's my question: is there some way to configure Spring Data REST to only expose rest endpoints for resources in the parent project, without having to explicitly annotate every repository in the dependency

When to use @RestController vs @RepositoryRestResource

不想你离开。 提交于 2019-12-17 17:26:36
问题 I have been looking at various examples of how to use Spring with REST . Our end target is a Spring HATEOAS/HAL setup I have seen two distinct methods for rendering REST within Spring Via @RestController within a Controller Via @RepositoryRestResource within a Repository The thing I am struggling to find is why would you use one over the other. When trying to implement HAL which is best? Our database backend is Neo4j . 回答1: Ok, so the short story is that you want to use the

With Spring Data REST, why is the @Version property becoming an ETag and not included in the representation?

心不动则不痛 提交于 2019-12-17 16:29:00
问题 In Spring Data REST (via Spring Boot 1.3.3), when I GET a resource collection of, say, people , the @Version property is not included with the resources: $curl -v http://localhost:8080/api/people/1 * Trying ::1... * Connected to localhost (::1) port 8080 (#0) > GET /api/people/1 HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/7.42.1 > Accept: */* > < HTTP/1.1 200 OK < Server: Apache-Coyote/1.1 < ETag: "0" < Last-Modified: Tue, 26 Apr 2016 00:08:12 GMT < Content-Type: application/hal+json

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

只谈情不闲聊 提交于 2019-12-17 08:25:12
问题 I'm currently building a REST API in which I want clients to easily filter on most properties of a specific entity. Using QueryDSL in combination with Spring Data REST (an example by Oliver Gierke) allows me to easily get to 90% of what I want by allowing clients to filter by combining query parameters which refer to properties (e.g. /users?firstName=Dennis&lastName=Laumen ). I can even customize the mapping between the query parameters and an entity's properties by implementing the

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

喜夏-厌秋 提交于 2019-12-17 08:25:06
问题 I'm currently building a REST API in which I want clients to easily filter on most properties of a specific entity. Using QueryDSL in combination with Spring Data REST (an example by Oliver Gierke) allows me to easily get to 90% of what I want by allowing clients to filter by combining query parameters which refer to properties (e.g. /users?firstName=Dennis&lastName=Laumen ). I can even customize the mapping between the query parameters and an entity's properties by implementing the

Why does RestTemplate not bind response representation to PagedResources?

蹲街弑〆低调 提交于 2019-12-17 08:24:54
问题 I am using spring-data-rest to expose entities as (paged) rest resources. Everything works fine, but when I request data via RestTemplate , I get an useless HATEOAS JSON (which I didn't ask for). The JSON seems to be a PagedResources. I could live with that, but the JSON isn't converted into an object correctly. There is no content inside. Repository: @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PersonRepository extends PagingAndSortingRepository

Use @JsonSerialize(using=MySerializer.class) on a @OneToMany Set<Object>

耗尽温柔 提交于 2019-12-13 16:29:24
问题 In a Spring Boot/Spring Data Rest project i have issues to use a custom JsonSerializer<Set<Object>> on a @OneToMany property. When i do an HTTP GET /collection request i have the following error: Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write content: Can not override serializer (through reference chain: org.springframework.hateoas.Resources["_embedded"]->java.util.UnmodifiableMap["analogParameters"]->java.util.ArrayList[0]);