spring-data-rest

Spring Data Rest Custom Controller

百般思念 提交于 2019-12-12 08:48:20
问题 I have requirement where in which i need to override the delete functionality from the rest Resource using a custom controller.here is the code for restResource @RepositoryRestResource public interface SampleRepository extends JpaRepository<Sample,Long>{ List<Sample> findBySampleNumber(@Param("sampleNumber") String sampleNumber); } i have created a a custom controller which overides only delete fuctionality @RepositoryRestController @RequestMapping("/api/samples") public class

Spring Data Rest - Include nested resource in _embedded

五迷三道 提交于 2019-12-12 07:20:52
问题 I'm developing a Spring Boot Application for a shopping list. For this I use Spring Data Rest to export my entities through a REST API. My Architecture looks like this I have a ShoppingItem : public class ShoppingItem { @Id @GeneratedValue private Long id; @ManyToOne @JoinColumn(name = "articleId", nullable = false) private Article article; private Integer number; private boolean bought; public ShoppingItem(){ this.article = null; this.number = 0; this.bought = false; } } This shopping item

How to establish relationships between Spring Data REST / Spring HATEOAS based (micro) services?

余生颓废 提交于 2019-12-12 07:15:23
问题 Trying to figure out a pattern for how to handle relationships when using a hypermedia based microservices based on Spring Data Rest or HATEOAS. If you have service A (Instructor) and Service B (Course) each exist as an a stand alone app. What is the preferred method for establishing a relationship between the two services. In a manner that does not require columns for IDs of the foreign service. It would be possible for each service to have many other services that need to communicate in the

How to create multiple resources with one Request in Spring Data Rest?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 06:17:49
问题 What do I need to implement in order to create multiple records in my DB with a single http request? I have a small Web-Application using SpringDataRest and JPA/Hibernate in which I can create resources with requests like this: curl -XPUT -H"Content-Type: application/json; charset utf-8"\ -d'{"id":"1","type":"test"}'\ http://localhost:8080/test/items/1 Instead, I would like to do something like: curl -XPUT -H"Content-Type: application/json; charset utf-8"\ -d'[{"id":"1","type":"test1"},{"id":

The way of passing complex params into spring date rest's method

不问归期 提交于 2019-12-12 04:39:35
问题 I am trying to find any info regarding the following issue: I have a JPA repository which was exposed to REST service with Spring Data Rest project: Page<Business> findByUser(@Param("user") User user, Pageable pageable); where the user parameter is the entity. Now when I try to call this REST method from client (with RestTemplate or Traverson) I can't understand how should I pass this param... Is it possible to implement it without making custom controller? Thank you in advance 回答1: I am

Spring Data Rest vs Spring Data Rest WebMvc

混江龙づ霸主 提交于 2019-12-12 03:38:19
问题 What is the difference between: spring-data-rest and spring-data-rest-webmvc To obviously they are two different things, but I am slightly confused here. 回答1: The spring-data-rest-webmvc is the project describing the main concepts of spring-data-rest which is the one of the main spring modules. In most cases one will use spring-data-rest dependency for his/her project. 来源: https://stackoverflow.com/questions/37999308/spring-data-rest-vs-spring-data-rest-webmvc

How to choose MappingContext in spring-data-jpa (2x) + spring-rest-webmvc?

99封情书 提交于 2019-12-12 02:11:59
问题 I've got a Module A that provides authentication through users, groups and related classes. This module uses org.springframework.data:spring-data-jpa:1.6.0.RELEASE to access this data from a database. Of note might be that Module A uses a custom BaseRepository configured by extending JpaRepositoryFactoryBean, but removing this does not resolve the issue below. A second Module B also has some classes and repositories to manage, unrelated to the Module A classes, again using spring-data-jpa for

use spring-boot internal @Controllers with @RequestParam to provide search method

心已入冬 提交于 2019-12-12 01:48:15
问题 I am building a back-end rest api with spring boot. Entity: @Entity public class Club { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; @NotNull @Column(unique=true) private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } Repository: @RepositoryRestResource public interface ClubRepository extends JpaRepository<Club, Long>, JpaSpecificationExecutor<Club> { } This alone exposes a rest endpoint at http://host

Spring Data Rest: ResourceProcessor configuration is not working properly

放肆的年华 提交于 2019-12-12 01:44:56
问题 I have a strange behaviour with a Spring Data Rest implementation (version 2.5.2.RELEASE). I'm trying to register a @Bean of ResourceProcessor<Resource<Entity>> , but there is something strange. I'm trying with two kinds of solutions: 1) Declaring the @Bean in a class: @Bean public ResourceProcessor<Resource<Author>> authorProcessor() { return new ResourceProcessor<Resource<Author>>() { @Override public Resource<Author> process(Resource<Author> resource) { System.out.println("method process

Avoid saving data in spring data rest in handleBeforeSave

浪尽此生 提交于 2019-12-11 23:52:48
问题 I am using @RepositoryRestResource for Mongo Repositories. I want to do some pre-save check and if those checks are not meeting the requirements, I want to abandon the save operation. I tried : @HandleBeforeSave public void handleBeforeSave(CallLog callLog) throws InternalServerException { CallLog log = callRepository.findOne(callLog.getConferenceId()); if (log != null && (callLog.getStatus().equals(Constants.CALL_IN_PROGRESS) || callLog .getStatus().equals(Constants.CALL_DROPPED))) { if