spring-data-rest

Spring Data Rest PUT v.s PATCH LinkableResources

。_饼干妹妹 提交于 2019-12-30 02:17:09
问题 I'm using Spring Data REST to expose my Entity's and their relationships. I have a OneToOne relationship between two Entity's and I'm trying to update/change the relationship with PUT and PATCH. I noticed that Spring Data REST will only allow you to update linked resources - JPA mapped Entity's (OneToMany, ManyToOne, etc) which are also AggregateRoots (has a Repository) - via a PATCH and are ignored with a PUT . This can be seen in the LinkedAssociationSkippingAssociationHandler class: if

How to add Custom Interceptor in Spring data rest (spring-data-rest-webmvc 2.3.0)

江枫思渺然 提交于 2019-12-29 07:42:20
问题 I am working on the spring data rest services & facing some issue in the custom interceptors. Earlier I used spring-data-rest-webmvc 2.2.0 & added interceptor in following way. public RequestMappingHandlerMapping repositoryExporterHandlerMapping() { RequestMappingHandlerMapping mapping = super .repositoryExporterHandlerMapping(); mapping.setInterceptors(new Object[] { new MyInterceptor() }); return mapping; } It worked perfectly fine for me. But when i upgraded to spring-data-rest-webmvc 2.3

How to add Custom Interceptor in Spring data rest (spring-data-rest-webmvc 2.3.0)

ぃ、小莉子 提交于 2019-12-29 07:42:09
问题 I am working on the spring data rest services & facing some issue in the custom interceptors. Earlier I used spring-data-rest-webmvc 2.2.0 & added interceptor in following way. public RequestMappingHandlerMapping repositoryExporterHandlerMapping() { RequestMappingHandlerMapping mapping = super .repositoryExporterHandlerMapping(); mapping.setInterceptors(new Object[] { new MyInterceptor() }); return mapping; } It worked perfectly fine for me. But when i upgraded to spring-data-rest-webmvc 2.3

Use case for Pagination of Embedded resources

試著忘記壹切 提交于 2019-12-29 07:11:39
问题 There is a use case I am struggling with SDR as below - THere is User Table and RefSecQuestion tables User -> ManyTOOne -> RefSecQuestion , RefSecQuestion -> OneToMany -> User THere is User Table and UserFriends tables User -> OneToMany UserFriends , UserFriends -> ManyToOne -> User There is a requirement that when I go /users/{id}/userFriends , then firstname , lastname etc from UserProjection should be shown by default As a result, I enabled excerptProjection in UserRepository and it works

Issue Serializing Lazy @ManyToOne

假装没事ソ 提交于 2019-12-29 06:29:08
问题 I am using Jackson's Hibernate4Module to deal with the serialization issues when dealing with a lazily loaded proxy in a Spring Data Rest project. In general it solves the issue of Jackson trying to serialise uninitialized proxies however one side effect is that the JSON output differs: Fetched directly: api/cases/5400 { "id": 5400, "practiceReference": "DWPYI9" } Fetched via a lazily loaded @ManyToOne: api/submissions/11901/parentCase { "content": { "id": 5400, "practiceReference": "DWPYI9"

Difference between @RestController and @RepositoryRestController

醉酒当歌 提交于 2019-12-29 05:47:45
问题 What is the typical use case code that shows the difference between those two annotations - meaning the @RestController and the @RepositoryRestController - ? 回答1: According to the annotation the RepositoryRestController is a way to provide custom controllers that still take advantage of spring data rest functionality http://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.overriding-sdr-response-handlers Sometimes you may want to write a custom handler for a

Spring Data REST custom query integration

二次信任 提交于 2019-12-28 08:12:10
问题 I want to create a REST link for an Employee entity that will basically be a findByAllFields query. Of course this should be combined with Page and Sort . In order to do that I have implemented the following code: @Entity public class Employee extends Persistable<Long> { @Column private String firstName; @Column private String lastName; @Column private String age; @Column @Temporal(TemporalType.TIMESTAMP) private Date hiringDate; } So I would like to have lets say a query where I can do: http

Spring Data REST custom query integration

筅森魡賤 提交于 2019-12-28 08:12:01
问题 I want to create a REST link for an Employee entity that will basically be a findByAllFields query. Of course this should be combined with Page and Sort . In order to do that I have implemented the following code: @Entity public class Employee extends Persistable<Long> { @Column private String firstName; @Column private String lastName; @Column private String age; @Column @Temporal(TemporalType.TIMESTAMP) private Date hiringDate; } So I would like to have lets say a query where I can do: http

@RepositoryRestResource's collectionResourceRel attribute not being obeyed

血红的双手。 提交于 2019-12-25 08:59:53
问题 I have a MongoRepository of @RepositoryRestResource(collectionResourceRel = "tools") public interface ToolRepository extends MongoRepository<Tool, Long> Tool can be one of 2 implementations: public class Screwdriver extends Tool public class Hammer extends Tool Tool is mapped using @JsonTypeInfo @JsonTypeInfo(use = com.fasterxml.jackson.annotation.JsonTypeInfo.Id.CLASS, include = As.PROPERTY, property = "_class") public abstract class Tool When I do toolRepository.findAll() this returns a

How to return representations of associations in a Spring Data REST resource?

孤街浪徒 提交于 2019-12-25 08:56:32
问题 There are following URLS - /users/2/profile , /users/2/userPosts I need to concat output of both Spring Data REST results in server side and build single JSON from them and send on different URL /users/2/custom . So, I am thinking to make 2 calls to SDR urls from Spring MVC, can we do this using RestTemplate and some JSON concat utility , here server and database is on same machine so RestTemplate will probably have localhost An example will help 回答1: You might rather want to look into the