spring-data-rest

Spring Data REST with Custom Resource URI Fails on PUT/PATCH - Spring Boot 2.0

淺唱寂寞╮ 提交于 2019-12-10 19:49:58
问题 I have a resource that is accessed via a custom resource URI. I have requirement that primary keys cannot be directly shown in a resource URI. So I modified my REST config to provided a modified EntityLookup. Appropriate snippets are as follows... Modified Configuration: @Component public class SpringDataMyDataRestCustomization extends RepositoryRestConfigurerAdapter { @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { /** * Setup hashed ID URIs *

Error on generating self link on pageable resource

非 Y 不嫁゛ 提交于 2019-12-10 16:39:21
问题 Make a simple RestController @RestController public class Controloler @Value class MyData { int value; } @GetMapping(value = "/datas", produces = MediaTypes.HAL_JSON_VALUE) public PagedResources<Resource<MyData>> getMyData(PagedResourcesAssembler<MyData> assembler, @RequestParam(required = false) String param, @PageableDefault Pageable pageRequest) { MyData data = new MyData(1); Page<MyData> page = new PageImpl<>(Collections.singletonList(data), pageRequest, 100); Link selfLink = linkTo

spring data rest update produce cross join sql error

笑着哭i 提交于 2019-12-10 16:06:57
问题 I want to use spring data rest to update rows of certain user , but at run time this query has strange "cross join" added to the query . spring data rest method @Modifying @Transactional @Query("Update Notification n SET n.noticed = true Where n.notificationPost.owner.userId = 1 ") public void postNoticed(); run time created query Hibernate: update notification cross join set noticed=true where owner_id=? My only concern is why "cross join" added as it gives sql error org.postgresql.util

Date issue in spring boot data rest

亡梦爱人 提交于 2019-12-10 15:17:26
问题 I'm having a problem with spring data rest when I'm handling dates. In a brief, it is delaying the date in one day. For example, if I have 1111-11-11 it returns to me 1111-11-10. There are some related post here in SO (ex1, ex2, ex3), but none of them solved the problem. I have an entity with this LocalDate : @Column(nullable=true) private LocalDate birthDate; I also have this repository: @RepositoryRestResource(collectionResourceRel = "person", path = "person") public interface

Can I specifically disable PATCH in spring-data-rest repository?

拥有回忆 提交于 2019-12-10 15:14:07
问题 Client of our API's don't use patch and I want to avoid it for maintenance overhead. I don't want to disable POST or PUT. 回答1: It can be handled at the security level, by extending WebSecurityConfigurerAdapter (available in spring-security-config) and overriding configure(HttpSecurity http) to deny PATCH requests to the target url : @Configuration @EnableWebSecurity public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity

Add relation to another node in SDN4 + REST

三世轮回 提交于 2019-12-10 13:56:22
问题 I have built a simple SDN4 + REST API: One endpoint, named player, which contains a set of properties. Each player has a Set<Player> friends property. GET, POST, PUT, DELETE and PATCH are working like charm on /player/{id} The problem here is /player/{id}/friends. I don't find out how to add a friend to a player, here is what I've tried so far: Before the Test: curl http://localhost:8080/api/player/1/friends : { } The Test curl -i -X PATCH -H "Content-Type:application/json" -d '{"id":1, "name

How to create link pointing to Spring controller action that returns void

China☆狼群 提交于 2019-12-10 13:21:10
问题 I am using spring mvc, hateoas. I have a controller action that looks like @RequestMapping(value = "/images/{userId}/{publicUrl}/{fileName:.+}", method = RequestMethod.GET) public void image(@PathVariable Integer userId, @PathVariable String publicUrl, @PathVariable String fileName, HttpServletRequest request, HttpServletResponse response) throws Exception { try(HellodoxAws aws = haws;){ ..... ..... response.setContentType(image.getObjectMetadata().getContentType()); response.setHeader("ETag"

ALPS metadata for all Spring-MVC Controller

吃可爱长大的小学妹 提交于 2019-12-10 12:46:54
问题 I've a question about the ALPS support in spring hateoas/data rest. It seems that the ALPS metadata are only exposed if you have a spring data rest repository. So my question is why is there only a support for the spring data rest repository and can I enable it for all spring mvc controllers? Is there any example to expose the ALPS metadata for all controllers? Maybe I haven't understood the conept of ALPS... Greets Meleagros http://spring.io/blog/2014/07/14/spring-data-rest-now-comes-with

Spring JPA Repository Sub-Query In Native Query

这一生的挚爱 提交于 2019-12-10 10:19:33
问题 I am trying to run a native query on a repository method so that it returns the results with some counts. It was too complicated to do with JPQL, so I opted for a native query instead. Repository @RepositoryRestResource(collectionResourceRel="projects", path="projects") interface ProjectRepository extends BaseRepository<Project, Long>, ProjectRepositoryCustom { @Query( value="SELECT p.id, p.user_id, p.title, p.description, p.created_on, p.version,(SELECT COUNT(0) FROM projectparts WHERE

Spring Data Rest : Foreign key is update with null after post call in one to many relationship

让人想犯罪 __ 提交于 2019-12-10 04:35:23
问题 I am using spring-data-rest . update and daily_update are 2 table which is having one to many relationship. Running this application with spring boot. When i am adding data using post request, entries being added into both table without any error but in child table (daily_update) column "update_id" (foreign key to update table) is coming null . I am using Lombok for setter and getter. Can you please help me with this? UpdateEntity class : @Data @Entity @Table(name = "update") public class