spring-data-rest

Spring Data Rest - Configure pagination

☆樱花仙子☆ 提交于 2019-11-29 08:31:26
Using Spring Data REST with JPA in version 2.1.0. How can I configure the pagination in order to have the page argument starting at index 1 instead of 0 ? I have tried setting a custom HateoasPageableHandlerMethodArgumentResolver with an mvc:argument-resolvers , but that doesn't work: <mvc:annotation-driven> <mvc:argument-resolvers> <bean class="org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver"> <property name="oneIndexedParameters" value="true"/> </bean> </mvc:argument-resolvers> </mvc:annotation-driven> Note that this behaviour is perfectly coherent with the

Use case for Pagination of Embedded resources

ⅰ亾dé卋堺 提交于 2019-11-29 08:17:32
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 fine. I expect about 100 results here so that is fine if this result is not paginated. But , now since

Spring boot starter data rest, @Notnull constraint not working

末鹿安然 提交于 2019-11-29 07:59:33
I am trying to add @NotNull constraint into my Person object but I still can @POST a new Person with a null email. I am using Spring boot rest with MongoDB. Entity class: import javax.validation.constraints.NotNull; public class Person { @Id private String id; private String username; private String password; @NotNull // <-- Not working private String email; // getters & setters } Repository class: @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface PersonRepository extends MongoRepository<Person, String> { } Application class: @SpringBootApplication

Spring Data Rest PagingAndSortingRepository AbstractMethodError (RepositoryFactorySupport)

倖福魔咒の 提交于 2019-11-29 07:23:53
问题 I'm trying to buil an Rest Api using Spring Data Rest, after to change my pom.xml many times to find the compatible dependencies to my project, I have this problem now: java.lang.AbstractMethodError: org.springframework.data.repository.core.support.RepositoryFactorySupport.getTargetRepository(Lorg/springframework/data/repository/core/RepositoryInformation;)Ljava/lang/Object; Once upon a time ... I have a Java Config Web App, my JPAConfig has these annotations @Configuration //

Why is the version property not set with Spring Data JPA?

六月ゝ 毕业季﹏ 提交于 2019-11-29 06:34:52
Wanted to know how is @Version annotation in Spring Data REST put to use for ETags, I do not see the ETags populated for some reason @Entity @EntityListeners(AuditingEntityListener.class) public class Venue implements Serializable { private static final long serialVersionUID = -5516160437873476233L; private Long id; ... // other properties private Long version; private Date lastModifiedDate; // getters & setters @JsonIgnore @LastModifiedDate public Date getLastModifiedDate() { return lastModifiedDate; } @Version @Column public Long getVersion() { return version; } Going by the docs this should

Spring Data Rest base path

一世执手 提交于 2019-11-29 05:44:40
问题 I have added Spring Data Rest (2.0) to an existing Spring MVC application by creating a Java config class that extends RepositoryRestMvcConfiguration, and adding @RestResource to the repositories. Is it possible to change the base URL for the Rest API? E.g: http://localhost:8080/rest/customers instead of http://localhost:8080/customers I tried to override configureRepositoryRestConfiguration using setBaseURI, but it didn't seem to apply to all links in the response. 回答1: As of Spring Boot 1.2

Resolving entity URI in custom controller (Spring HATEOAS)

霸气de小男生 提交于 2019-11-29 05:36:40
I have a project based on spring-data-rest and also it has some custom endpoints. For sending POST data I'm using json like { "action": "REMOVE", "customer": "http://localhost:8080/api/rest/customers/7" } That is fine for spring-data-rest, but does not work with a custom controller. for example: public class Action { public ActionType action; public Customer customer; } @RestController public class ActionController(){ @Autowired private ActionService actionService; @RestController public class ActionController { @Autowired private ActionService actionService; @RequestMapping(value = "/customer

Paginate sub-resources in Spring Data Rest 2.1

天涯浪子 提交于 2019-11-29 04:49:59
I use Spring Data Rest 2.1.1 Release with the default configuration. Considering the following resource: GET /communities/MyCommunity { "creationDate": "2014-07-16T06:22:37.153+0000", "name": "GroupeSEB", "_links": { "self": { "href": "http://localhost:8080/api/communities/GroupeSEB" }, "posts": { "href": "http://localhost:8080/api/communities/GroupeSEB/posts" } } } When I get the "posts" sub-resource : GET /communities/MyCommunity/posts { "_embedded": { "posts": [ { "creationDate": "2014-07-09T13:09:14.535+0000", "id": "53bd3efae4b012818368c549", "_links": { "self": { "href": "http:/

Spring Data REST - PUT request does not work properly since v.2.5.7

浪子不回头ぞ 提交于 2019-11-29 03:47:27
Since version 2.5.7 Spring Data REST does not properly perform a PUT request to update resource which has associated resources . Unlike PATCH request that works as expected! For example, Person has a many-to-one association with Addres . If we perform a PUT request with SDR v.2.5.6 (Spring Boot v.1.4.3) then all works OK. But if we switch to version 2.5.7 (i.e. to Spring Boot v.1.4.4) then we get an error: Can not construct instance of Address: no String-argument constructor/factory method to deserialize from String value The same happens with other types of associations, for example with one

Spring Data REST in plain JSON (not HAL format)

瘦欲@ 提交于 2019-11-29 03:34:50
问题 How exactly should Spring Data Rest be configured to return plain JSON instead of HAL (JSON with Hypermedia like links) Related Spring returns Resource in pure JSON not in HAL Format when including spring data rest Spring Data Rest -Disable self links(HAL) in Json and big Disable Hypertext Application Language (HAL) in JSON? using jsonapi instead of HAL Changing the JSON format for spring-data-rest 回答1: Add the below property to your application.properties or yml . By default it is