spring-data-rest

Spring JPA REST sort by nested property

淺唱寂寞╮ 提交于 2021-02-17 21:45:01
问题 I have entity Market and Event . Market entity has a column: @ManyToOne(fetch = FetchType.EAGER) private Event event; Next I have a repository: public interface MarketRepository extends PagingAndSortingRepository<Market, Long> { } and a projection: @Projection(name="expanded", types={Market.class}) public interface ExpandedMarket { public String getName(); public Event getEvent(); } using REST query /api/markets?projection=expanded&sort=name,asc I get successfully the list of markets with

Spring JPA REST sort by nested property

五迷三道 提交于 2021-02-17 21:43:35
问题 I have entity Market and Event . Market entity has a column: @ManyToOne(fetch = FetchType.EAGER) private Event event; Next I have a repository: public interface MarketRepository extends PagingAndSortingRepository<Market, Long> { } and a projection: @Projection(name="expanded", types={Market.class}) public interface ExpandedMarket { public String getName(); public Event getEvent(); } using REST query /api/markets?projection=expanded&sort=name,asc I get successfully the list of markets with

Timestamp converter not working in Spring Data Rest with Spanner

て烟熏妆下的殇ゞ 提交于 2021-02-11 18:18:37
问题 I'm trying to convert the input timestamp which will be in the string format to cloud timestamp with the help of a Spring Data Rest custom converter which is not working. Need an help on the same in understanding why custom converters are not invoked. Input: http://localhost:8080/apipromocentral/promotions RequestBody : {"startDateTime": "2019-11-07 15:53:00"} POJO: @ApiModel @Data @AllArgsConstructor @Table(name = "PROMOTIONS") public class Promotion { /** * promotion id */ @ApiModelProperty

Timestamp converter not working in Spring Data Rest with Spanner

空扰寡人 提交于 2021-02-11 18:17:06
问题 I'm trying to convert the input timestamp which will be in the string format to cloud timestamp with the help of a Spring Data Rest custom converter which is not working. Need an help on the same in understanding why custom converters are not invoked. Input: http://localhost:8080/apipromocentral/promotions RequestBody : {"startDateTime": "2019-11-07 15:53:00"} POJO: @ApiModel @Data @AllArgsConstructor @Table(name = "PROMOTIONS") public class Promotion { /** * promotion id */ @ApiModelProperty

Reproducing Spring Data Rest search controllers in Spring Boot 2.3

旧时模样 提交于 2021-02-11 12:32:17
问题 Until Spring Boot 2.0, I could reproduce the controllers generated for query methods exposed by a mongodb repository. Here is a code sample: Domain Entity @Document(collection = "foos") public class Foo { @Id private String id; private String name; // getters/setters omitted } Mongo repository public interface FooRepository extends MongoRepository<Foo, String> { public Page<Foo> findByName(@Param("name") String name, Pageable pageable); } Spring Boot automatically exposes the search method

Spring Data Rest projection sorting

别说谁变了你拦得住时间么 提交于 2021-02-07 20:21:05
问题 I have a projection for my entity and I need to sort it by field of inner class. This is part of my entities: class Person { UUID guid; Set<DisabilityHistory> disabilityHistory; } class DisabilityHistory { Date createdDate; } I know about sort param but request like api/person/search?projection=myProjection&sort=disabilityHistory.createdDate,asc doesn't work. The only solution I have found is using @OrderBy annotation in my entity but in this case it will sorted always and I worried about

@Autowire MockMvc - Spring Data Rest

允我心安 提交于 2021-02-07 18:41:36
问题 Given the Repository public interface ResourceRepository extends CrudRepository<Resource, Long> { ... } The following test code: @WebMvcTest @RunWith(SpringRunner.class) public class RestResourceTests { @Autowired private MockMvc mockMvc; @Test public void create_ValidResource_Should201() { String requestJson = "..."; mockMvc.perform( post("/resource") .content(requestJson) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isCreated()); // This fails with 404 } } In order to fix

Enabling cross origin requests in Spring Data Rest

 ̄綄美尐妖づ 提交于 2021-02-07 08:26:56
问题 I have a web application that I am developing using Angular 2 and Spring Boot. I use the spring-boot-data-rest dependency to expose my repositories as HTTP endpoints. During development, I run my backend spring boot project on a local tomcat that runs on port 8080. To develop the frontend, I use the angular-cli to serve my Angular 2 application on port 4200. My frontend running on 4200 needs to be able to hit the endpoints exposed on 8080, but that doesn't work because: No 'Access-Control

Enabling cross origin requests in Spring Data Rest

僤鯓⒐⒋嵵緔 提交于 2021-02-07 08:24:06
问题 I have a web application that I am developing using Angular 2 and Spring Boot. I use the spring-boot-data-rest dependency to expose my repositories as HTTP endpoints. During development, I run my backend spring boot project on a local tomcat that runs on port 8080. To develop the frontend, I use the angular-cli to serve my Angular 2 application on port 4200. My frontend running on 4200 needs to be able to hit the endpoints exposed on 8080, but that doesn't work because: No 'Access-Control

How to use Pageable as get-query parameter in spring-data-rest?

故事扮演 提交于 2021-01-29 13:21:31
问题 I have a simple query controller that takes query parameters (as Person dto) and a Pageable : @RestController public class PersonController { @GetMapping("/persons") public Object search(org.springframework.data.domain.Pageable pageable, Person form) { repository.findAll(form, pageable); } } The pageable can take both sort and page parameters as follows: http://localhost:8080/persons?sort=age,desc&page=5 Problem: for the sort, I want to add order hints like NULLS_LAST or NULLS_FIRST .