spring-data-rest

Testing Spring Data Rest endpoints using RestTemplate not working in SpringBoot 2.0.0.BUILD-SNAPSHOT

徘徊边缘 提交于 2019-12-13 07:30:40
问题 I am using Spring Data REST for exposing Spring Data JPA repositories as REST endpoints. @Entity @Table(name = "USERS") public class User implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private String name; private String email; private String password; } public interface UserRepository extends JpaRepository<User, Integer> { } While using SpringBoot 1.5.3.RELEASE I could test the endpoint http://localhost:8080/users using RestTemplate as

Set disallowed fields in Spring Data Rest

感情迁移 提交于 2019-12-13 05:17:45
问题 I want to exclude certain fields from a POST to my repositories. For example I want to set the version myself so users cannot set this field themselves. For example in the class below. @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; @CreatedDate private LocalDateTime created; @LastModifiedDate private LocalDateTime lastModified; private String name; } I have tried to use the @ReadOnlyProperty annotation and not having a setter for the version

Sping Data REST Endpoints Not Generating In Swagger UI

本秂侑毒 提交于 2019-12-13 04:16:35
问题 I've implemented a controller using @BasePathAwareController which also takes advantage of Spring Data REST (for finds to expose sort/size etc.) along with some custom endpoints (for updates etc.). The application is working as expected and the endpoints Spring Data REST generates are working as expected and I can see the self links appear in the responses, however, i can't see these endpoints in Swagger UI. I can just see my custom endpoints defined in my Controller. According to this post I

Bookmark AngularJS frontend (direct access) - Spring Data Rest backend

。_饼干妹妹 提交于 2019-12-13 00:34:03
问题 I've started to implement a web-front end to manipulate a RESTful service served by Spring Data Rest over a traditional relational DB. This is done with AngularJS and the angular-hal library that I found fits very well the HATEOAS philosophy and formalism of Spring Data Rest . For example, I just need to know the first API endpoint ('/'), and then all of my queries are done through the relations without caring for the urls. The problem I have is to be able to directly access the page

Kotlin data class No String-argument constructor with spring data rest

浪尽此生 提交于 2019-12-12 23:17:39
问题 I'm using Spring data rest with Kotlin and if I use data classes the associations via uri stops working with the error no String-argument constructor/factory method to deserialize from String value Data class @Entity data class Comment( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long = 0, var author: String? = null, var content: String? = null, @ManyToOne var post: Post? = null) { } If I use a simple class instead the association works fine. @Entity class Comment { @Id

Filter results from QueryDSL search

余生长醉 提交于 2019-12-12 22:06:08
问题 I'm using QueryDSL as part of Spring Data Rest to search entities from our API. Is it possible to somehow filter the search API, so that by default it won't find for example Car entities that are "deactivated"? Currently I've a flag on car entity that when it's set to true, it shouldn't be exposed through our search API, and the cars that have this property set should be left out from search. https://docs.spring.io/spring-data/jpa/docs/1.9.0.RELEASE/reference/html/#core.web.type-safe 回答1: In

Spring Data Rest - PUT on repository silently fails on child references

穿精又带淫゛_ 提交于 2019-12-12 20:28:30
问题 I use Spring Data Rest with Spring Boot 2.1.1.RELEASE. I have a class User with a @ManyToMany relationship to a class Skill . When I make a POST to create a user with his skills, everything works finely. When I make a PUT to update a user, the skills are not updated, no error is produced. But when I make a PATCH instead of a PUT , the skills are correctly updated. Have anyone met a similar issue? I have found another (old) question about it, but there isn't solution (Spring Data Rest - PUT is

Use Spring-Data-Rest to return response as XML instead of JSON

半腔热情 提交于 2019-12-12 16:18:22
问题 Spring-data-rest is currently RC1 (heading for GA July 16), but the documentation is still a little sketchy. So far all the example code I find shows responses defaulting to JSON, but I need XML, and ideally either XML or JSON based on ACCEPT header. I found one source in some comments in a DZone link that indicate XML is going to be supported. But that was posted during the M2 release, before RC1. I don't see anything in the Issues under the project either. So does anybody know how to make

Upsert Mongo Document using spring data mongo

笑着哭i 提交于 2019-12-12 13:33:17
问题 I have a Class @Document public class MyDocument { @Id private String id; private String title; private String description; private String tagLine; @CreatedDate private Date createdDate; @LastModifiedDate private Date updatedDate; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getDescription() { return description; } public void

SpringDataRest @RepositoryEventHandler not running when Controller is added

不羁岁月 提交于 2019-12-12 11:34:09
问题 I have an event handler that runs perfectly fine on a repository. However once I add a controller into the mix and call the repository method directly, the EventHandler seems to be skipped over. Has anyone encountered this "issue"? If so, what can I do to get the event handler to start running again? 回答1: So you expect that your event handler is called when you use a custom controller. I think this expectation is false. The event handler is just called when spring data rests