Questions tagged [spring-data-rest]

Spring Data REST (SDR) is a Spring Data project that aims to make it easy to expose Spring Data repositories as REST services. SDR use Spring HATEOAS internally to create HAL response.

Filter by
Sorted by
Tagged with
0 votes
0 answers
35 views

How to make Spring Data REST fail on a DB constraint error on POST?

I have a table with a composite primary key of the following structure: create table follows ( source_id bigint references users on delete cascade, target_id ...
Mikhail Oleynikov's user avatar
0 votes
1 answer
28 views

Why does Spring Data REST ignore cascade ops on an associated entity?

Background I have an Car entity with a @ManyToOne relationship with a Make entity: @Entity public class Car { @Id Long id; @ManyToOne(cascade = CascadeType.ALL) Make make; } @Entity public ...
James's user avatar
  • 2,984
0 votes
1 answer
22 views

Cannot instantiate Querydsl Predicate in Spring Data Rest

I don't see why Spring try to instantiate my Predicate by interface. What configuration is responsible for binding predicate from http parameters? I have exception: No primary or single unique ...
Cezary's user avatar
  • 23
0 votes
0 answers
15 views

model mapper not being able to map a nested entity to a dto

So I have a Review entity and a Campaign entity with each of its own DTOs. I put the Campaign entity as a whole field to the Review entity and put all the Campaign entity fields in the ReviewDTO field ...
babyybiss's user avatar
0 votes
0 answers
48 views

How can I convert an Object to a JSON reperesentation using Spring Data REST outside of RestController?

I have a project based on Spring Data REST for providing an API to interact with a database. I am using also an EntityListener to handle the update callbacks to all the entities of the project. In ...
MickeyMouse's user avatar
0 votes
1 answer
33 views

How to add api doc to generated spring jpa endpoints

I'm trying do document my Spring Data REST API with OpenAPI with spring-doc. I have my custom endpoints with my custom comments and examples, works fine. But what about the generated endpoints? For ...
Juliane's user avatar
  • 87
0 votes
0 answers
31 views

Disable profile controller in spring boot

I'm using spring boot with external oauth2 server. I configure it using standard spring boot oauth2 resourceserver and spring data rest. Application expose profile controller, but this function is ...
Cezary's user avatar
  • 23
1 vote
0 answers
40 views

Object creation with read only JSON field is not working in Spring Data Rest and Kotlin

In my Spring Boot application, I want to set fields non nullable in database and Kotlin, but I don't want to make them writable in the Spring Data Rest API. I prefer to avoid writing a full custom ...
Grum's user avatar
  • 181
0 votes
1 answer
17 views

How do I use JavaScript Traverson HAL $all meta selector?

Per the JavaScript Traverson HAL documentation For embedded arrays you can additionally use the meta selector $all, which operates on embedded documents: If you pass ht:post[$all] to the follow ...
James's user avatar
  • 2,984
0 votes
0 answers
46 views

Cannot use UUID in APIs generated by Spring Data Rest

I have below entity configuration @Entity @RestResource public class Employee { @Id @GeneratedValue @Type(type = "pg-uuid") private UUID id; @OneToMany(mappedBy = "...
user09's user avatar
  • 950
1 vote
1 answer
135 views

How do I configure Spring Data REST to return links with templated ID such as users/{id}

Suppose I have Spring Data repository for a User entity. Then, Spring Data REST produces the following HAL JSON at its base path: { "_links": { "users": { "href&...
James's user avatar
  • 2,984
0 votes
0 answers
72 views

Is there a Spring Data REST equivalent for GraphQL schemas?

Is there an equivalent to Spring Data REST for GraphQL? More specifically a library that automatically generates GraphQL schemas and query-, schema- and batch-mappings based on a noSQL schema in the ...
Ivan Janssens de Varebeke's user avatar
0 votes
0 answers
21 views

Compare changed fields in @PreAuthorize function

I'm writing a spring application which uses spring-data-rest to expose a restish API for CRUD operations on my entities. I'm using role based permissions and most of my entity repositories have either ...
Simon Lenz's user avatar
  • 2,762
0 votes
0 answers
39 views

Spring Data REST: force openapi schema export

When working with SDR, I need that the associated resources are expanded in the returned JSON. I have achieved this by adding @RestResource(exported = false) to the associated resource. For example: @...
FkJ's user avatar
  • 1,638
0 votes
1 answer
46 views

Which repository for sorting on a nested entity property using Spring Data JPA?

I want to get sorted list of Models for a given set of Car vins. The following repository query attempts to do this: @Query("select distinct c.model" + "from Car c " ...
James's user avatar
  • 2,984
0 votes
0 answers
42 views

Choosing Between Spring Data REST Endpoint and JpaRepo

As a newcomer to Spring Boot, I have encountered the Spring Data REST framework, which offers convenient endpoints for CRUD operations. In my specific scenario, I need to execute custom business logic ...
Okba Samir's user avatar
0 votes
1 answer
58 views

Can I use a @RequestParam as a @Query parameter when using Spring Data Rest?

I'm using Spring Data Rest, my Repository extends JpaRepository and I want to create a custom query with @Query. My method parameter is a @RequestParameter and I want to use it as a parameter for the ...
m_jdm35's user avatar
  • 41
0 votes
1 answer
52 views

RepositoryRestController: POST with multiple HAL URI

I've OneToMany relation between User & Address and ManyToOne relation with EmploymentType. @Entity public class User { //.. private String name; @ManyToOne private EmploymentType ...
Kiran Kyle's user avatar
1 vote
3 answers
2k views

Spring Boot WebClient Request gives block terminated error

I am making a call from a Vehicle service class containing a WebClient to a Price microservice for which I have used Spring Data Rest. I created a custom method to re-calculate a price for an id ...
Othello's user avatar
  • 55
0 votes
0 answers
48 views

how to use spring data rest with multiple boot apps

I have two aggregate roots, Account which holds id, name and Alert which holds id, title and Account(@ManyToOne). Using spring boot with data-jpa and data-rest I can see the full magic in swagger-ui. ...
tomer.kalich's user avatar
0 votes
0 answers
34 views

Fallback for Spring Data REST link generation when no current request is available

I have a spring-data-rest & spring-hateoas app powering a UI that depends heavily on the presence of the _links field in all responses. This has been working well. However I have a need to ...
sonicrocketman's user avatar
1 vote
1 answer
614 views

Spring Boot Kotlin data class not initailized with default values in REST controller

I have started migrating a Spring Boot application from Java to Kotlin. Before, everything worked perfectly. Now I can't update any Entity received through PUT/POST, because the data doesn't contain ...
Stefan Garlonta's user avatar
0 votes
1 answer
167 views

Spring Data Rest - Post Request failing with Null Pointer Foreign Key Exception

I am having a Spring Data rest API where I am trying to save a new record in Entity named comment. This entity has a many to one relationship with another entity named department. When I call the post ...
Saimuga's user avatar
  • 255
1 vote
0 answers
75 views

Why isn't Spring Data Rest compatible with Spring's Feign on query parameter list?

Using @FeignClient to pass a collection via: @GetMapping("/api/cars/search/findCarsByIdIn") CollectionModel<Cars> getCars( @RequestParam("carIds") ...
James's user avatar
  • 2,984
0 votes
0 answers
22 views

Is it possible to have spring controller directly map a URI to entity?

I use the framework Spring Data Rest for my API end points and controller. I want to take in an URI to an entity and have spring convert it automatically For many years the way I've been doing it this ...
erotsppa's user avatar
  • 14.5k
0 votes
1 answer
40 views

Add link to Spring Data REST Repository resource with RepresentationModelProcess

The Spring Data Rest repository notes that Custom Links can be added to an Entity as below: https://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr.customizing-json-output....
offenbach's user avatar
3 votes
1 answer
739 views

Getting "Only Single Level Inheritance Supported" Error with SpringBoot Eureka Feign Client

I am working through a tutorial creating a eureka server and eureka client. Prior to adding the feign client, the eureka client is able to register with the eureka server. After I added the feign ...
Othello's user avatar
  • 55
0 votes
0 answers
19 views

How to add a parent class without document reference with only common parameters and apply Inheritance concept in Spring boot using MONGO

I have 2 collections in mongodb, property_report_order { "_id" : ObjectId("63e1ee7a89252e00253e112a"), "userId" : ObjectId("62ce989e896a890026078fac"),...
Gayathri Rajan's user avatar
0 votes
0 answers
56 views

What's the correct way to proxy TestRestTemplate connections?

I waned to redirect TestRestTemplate trough proxy. The difficult part for me is that I cannot create new TestRestTemplate because I am using it inside Spring Boot test so I have to use @Autowired. @...
u4963840's user avatar
0 votes
0 answers
1k views

Exception while trying to connect to mangodb -- org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017

i am trying for the firsttime, to connect to mongodb. and i get the exception and so connectiion is refused. I am using SprintBoot3.0 and below are the Maven Depedencies. <parent> <...
Kalpana's user avatar
0 votes
1 answer
140 views

How to enforce CORS with Spring Boot Data Rest?

I have created a Sing Data Repository and made it accessible through Spring Data REST (Spring Boot 2.7.2). I would expect it to reject any CORS, but it does not happen. I double-checked: I have ...
Franco G's user avatar
  • 374
1 vote
1 answer
51 views

Using Spring Data Rest POST for linking

I'm creating a user registration form in React. My backend is Spring Data Rest. The registration form has firstName, lastName, username, city & country fields. city & country fields are ...
Kiran Kyle's user avatar
1 vote
0 answers
72 views

Is there a way to create a link to a RepositoryRestController from a normal RestController?

I am trying to create a link to a RepositoryRestController from a normal RestController. The links being created by WebMvcLinkBuilder do not contain the expected spring.data.rest.basePath. ...
Chris Jurcina's user avatar
1 vote
0 answers
353 views

Injection in custom Validator return null

I have already looked in stackoverflow and other websites but found nothing which worked for me. (Spring boot 3) Log : Resolved [jakarta.validation.ValidationException: HV000028: Unexpected exception ...
R Am's user avatar
  • 21
0 votes
0 answers
522 views

Update field in @ManyToOne relationship using Spring Data JPA

I am trying to change the task status (there are 3 permanent tasks in the database: To do, In progress, Done). I tried to use Spring Data JPA's built-in REST and the patch method but it doesn't work ...
stealthoust's user avatar
0 votes
1 answer
213 views

Get Logged-in User

Please bare with me as I am learning Spring Data REST as I go. Definitely feel free to suggest a safer approach if what I am proposing here is not the safest approach or even possible. Problem A user ...
fire_water's user avatar
  • 1,400
0 votes
0 answers
119 views

Post nested objects with Spring Data REST

I'm trying using Spring Data Rest in a Spring Boot backend. I have an entity named Request with some fields and another entity named RequestData. Now, RequestData's mapped table has the foreign key ...
Carmelo Fortunato's user avatar
0 votes
0 answers
19 views

What is the best backend-id-conversion for composite primary key

I'm trying to use BackendIdConverter for my entities and repositories. For those entities with compound primary keys, I'm using JSON encoding/decoding. The uri is ugly. { "_embedded": { ...
Jin Kwon's user avatar
  • 20.7k
-1 votes
1 answer
203 views

Why does Spring Security not prevent POST request for USER role? [duplicate]

A Spring UserDetailsService contains an admin with role ADMIN and an user with role USER: @Bean public UserDetailsService uds() { UserDetails admin = User.builder() .username("admin&...
TMOTTM's user avatar
  • 3,326
0 votes
0 answers
31 views

Spring Pageable parses "Sort" wrongly?

Using MongoDb and @RepositoryRestController and Pageable from Spring. Controller method(passing in -- ?page=0&size=20&sort=events.field1,asc): ..WithCreator(@RequestBody ..., @ParameterObject ...
Daniel Jeney's user avatar
0 votes
0 answers
26 views

Can I use Method Security on Spring Rest Repository methods?

Let CountryRepo be a Spring RepositoryRestResource @RepositoryRestResource public interface CountryRepo implements CrudRepository<Country, Long> { } for a simple Country domain with country ...
TMOTTM's user avatar
  • 3,326
0 votes
0 answers
30 views

Spring Data Rest - Manage child entities when only parent has a repository

I have a Spring backend that is using Spring Data Rest. I have a One-To-Many relation where the parent has its own repository but the children don't. I've chosen to do it this way because the child ...
Krisztian's user avatar
  • 375
0 votes
0 answers
14 views

spring-data-rest @ManyToMany

I am working on a spring-data-rest module, but there is a problem in the query process: I defined the roles attribute in the User class, added @ManyToMany annotation, and printed relevant sql about ...
pan chengjian's user avatar
0 votes
1 answer
1k views

ConverterNotFoundException: No converter found capable of converting from type [org.bson.types.Binary] to type [java.util.UUID]

I have a small standard Spring Boot microservice which is Spring Data REST for a single Mongo DB collection. The document contains the UUID field. The collection is a capped collection due to ...
Serhii Mormul's user avatar
3 votes
0 answers
46 views

Hibernate Enverse in Java is using Proxies instead of Bags

Currently i'm worrking on a Java project which uses JPA and under the hood Hibernate as its ORM. Furthermore we're using Enverse as our auditing Library. Now, when i query an entity which contains a @...
Dignity's user avatar
  • 51
1 vote
0 answers
31 views

Custom aggregated query with spring boot data REST

I'm pretty new to Spring Boot and Spring Data Rest and HATEOAS. I'm able to create a REST API with CRUD capability on an entity (say Device, entity having a few properties, including one called ...
Roberto's user avatar
  • 898
0 votes
1 answer
42 views

Why does deleteBy methods in spring data work only with GET requests

I'm using Spring Data Rest and I have an Entity employee public class Employee { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private int id; @Column(name = &...
Karim Ater's user avatar
0 votes
1 answer
176 views

Spring Data: Page information missing fron response on using CollectionModel with RepositoryRestController

My repository method is: public Page<Order> findByStatusIn(List<OrderStatus> orderStatuses, Pageable pageable); Which is called from Controller (@RepositoryRestController) as : Pageable ...
Shoreki's user avatar
  • 1,057
0 votes
0 answers
37 views

Caching GET method of @RepositoryRestResource

I have a @RespositoryRestResource class. Only the GET operation is being used which returns all the data. This is taking some time. So I want to cache this call. However I'm not sure how to achieve ...
Hari Narayanan's user avatar
0 votes
3 answers
493 views

id property inherited from AbstractPersistable is not recognized in a Spring Boot AOT compiled native image

I have migrated a Spring Boot application to Spring Boot 3 and compiled a native image. The application is exposing a simple entity using Spring Data REST (see code below). During application startup ...
Martin Ahrer's user avatar

1
2 3 4 5
45