spring-data-rest

Spring Data Rest - Configure pagination

拈花ヽ惹草 提交于 2019-11-28 02:01:31
问题 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

How to customize Spring Data REST to use a multi-segment path for a repository resource?

二次信任 提交于 2019-11-28 01:51:24
I'm developing a component based CRUD application using Spring Data JPA and Spring Data REST. I have several components. For example system component has the User model and the UserRepository . Components are differenciated by the package names. like com.example.app.<component_name> So to make my REST API look cleaner, I need to implement the API URL as below. host:8080/<component_name>/<model_collection_name> for example host:8080/system/users I did the following in my repository @RepositoryRestResource(collectionResourceRel = "users", path = "system/users") public interface UserRepository

Spring Boot LocalDate field serialization and deserialization

浪子不回头ぞ 提交于 2019-11-28 01:35:29
问题 On spring boot 1.2.3.RELEASE with fasterxml what is the correct way of serializing and de-serializing a LocalDate field to iso date formatted string? I've tried: spring.jackson.serialization.write-dates-as-timestamps:false in application.properties file, including jackson-datatype-jsr310 in project and then using @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") annotation and @DateTimeFormat(iso=ISO.DATE) annotation, adding Jsr310DateTimeFormatAnnotationFormatterFactory as

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

情到浓时终转凉″ 提交于 2019-11-28 00:15:47
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;charset=UTF-8 < Transfer-Encoding: chunked < Date: Tue, 26 Apr 2016 00:12:56 GMT < { "id" : 1,

Resolving entity URI in custom controller (Spring HATEOAS)

南楼画角 提交于 2019-11-27 23:30:15
问题 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

How to configure Spring HATEOAS behind proxy?

亡梦爱人 提交于 2019-11-27 23:06:48
I have Spring Data Rest with Hateoas as my backed. It is behind a proxy. Backend url: backend.com Proxy url: proxy.com When I query proxy url, e.g. http://proxy.com/items/1 , I get a response with href links with domain backend.com . I need the domain to be proxy.com . As of Spring-Boot 2.1 / Spring 5.1, Spring shifts the responsibility of handling X-Forwarded-* from Spring HATEOAS to Spring MVC. https://jira.spring.io/browse/SPR-16668 You now require the registration of a filter bean. Minimal implementation: @Bean FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() {

Custom jpa repository method published by spring-data-rest

微笑、不失礼 提交于 2019-11-27 22:23:46
I've added a custom method to a jpa repository as detailed on http://docs.spring.io/spring-data/data-jpa/docs/1.0.x/reference/html/#repositories.custom-implementations As far as I could see, this method is not exposed when I use spring-data-rest. Is there any way I could publish it as part of the REST API generated by spring-data-rest (without creating a Spring MVC Controller myself)? I checked the code base - seems like they have explicitily disabled custom methods - not sure why. Here is the relevant piece of code from org.springframework.data.repository.core.support

Spring Data REST @Idclass not recognized

人盡茶涼 提交于 2019-11-27 20:51:59
I have an entity named EmployeeDepartment as below @IdClass(EmployeeDepartmentPK.class) //EmployeeDepartmentPK is a serializeable object @Entity EmployeeDepartment{ @Id private String employeeID; @Id private String departmentCode; ---- Getters, Setters and other props/columns } and I have a Spring Data Repository defined as as below @RepositoryRestResource(....) public interface IEmployeeDepartmentRepository extends PagingAndSortingRepository<EmployeeDepartment, EmployeeDepartmentPK> { } Further, I have a converter registered to convert from String to EmployeeDepartmentPK. Now, for an entity,

Selectively expand associations in Spring Data Rest response

独自空忆成欢 提交于 2019-11-27 19:09:52
I have a standard Spring data JPA and Spring data Rest setup which, correctly, returns associations as links to the correct resources. { "id": 1, "version": 2, "date": "2011-11-22", "description": "XPTO", "_links": { "self": { "href": "http://localhost:8000/api/domain/1" }, "otherDomain": { "href": "http://localhost:8000/api/domain/1/otherDomain" } } } However in some requests i would like to have the association to the "otherDomain" expanded (so the client does not have to do N+1 requests to get the full data). Is it possible to configure Spring Data Rest to handle the response in this way?

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

江枫思渺然 提交于 2019-11-27 17:53:39
问题 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