Now I know how to findBySomething on root level entity. Let’s say I have a one to many relation of class -> student I can now students/search/findByName?name=Tom But it will give me Tom in all classes. Can I do something like classes/1/students/search/findByName?name=Tom It gives error right now. Ans…
Tag: spring-data-rest
Spring Boot 2.3.x – How to apply a projection in a custom @RestController?
I am trying to apply projection on an entity returned from a custom controller annotated @RestController. But I am getting an infinite recursion exception This code works fine in Spring Boot 1.5.17 (I can apply projections and even get HAL formatted JSON) but it breaks in Spring 2.3.x. So what I essentially w…
Column ‘foreign_key_id’ cannot be null
I have a rest api exposed via @RepositoryRestResource from spring-data-rest-api. When I try to give the json payload from Postman to create a User linked to an Organization, it complains that Column ‘organizationId’ cannot be null, when I clearly provided it in the json. Each user belongs to an or…
“org.springframework.data.util.TypeInformation.getActualType()” because “propertyType” is null
A Spring Boot 2.5.1 application is logging this warning: whereas Spring Boot 2.4.4 does not. The POJO is trivial: and the Spring RestController is similarly: To trigger the warning submit a POST: The warning is triggered while “handling” the _links property of the EntityModel<SoPojo> but why…
Add database authentication to Spring Data Rest application
I’m creating an application using Spring Data REST with Thymeleaf. Initially I created my models, controllers, dao and services. All worked fine. I’m now trying to add security to my application. Right now I’m just focused on the login/logout. I’ve been able to create an in memory auth…
How to properly filter Spring REST data
I have a Spring Data REST service with a single @Entity and Repository. When I run $ curl localhost:8080/api I get all the data stored in my repository and it works as expected. I also have a small React front end and I display that data there. My question is: Where should I filter the data? For example maybe…
How to properly access a secured Spring Data REST Repository in a ApplicationRunner?
I followed the documentation on how to secure REST repositories with @PreAuthorize. However, the following repository needs to be accessed by an ApplicationRunner to perform some initial setup tasks after application startup. Since there’s no security context active when this runner is executed the appl…
Spring Data Rest – Soft Delete
I’ve been using spring data rest without any problem but now I have a requirement that when a user performs a DELETE operation on a given entity i.e. DELETE /accounts/<id> I need to set a flag on the database marking that entity as deleted but i do want to keep the record. Basically this means tha…
How to disable the default exposure of Spring Data REST repositories?
I have a project that uses spring-data-rest, and has a dependency project that only uses Spring Data. Both projects have spring data repositories and use @EnableJpaRepositories to implement their repository interfaces, but I only want to export the repositories in the parent project. Here’s my question:…