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.
Questions tagged [spring-data-rest]
2228 questions
115
votes
6 answers
JSON parse error: Can not construct instance of java.time.LocalDate: no String-argument constructor/factory method to deserialize from String value
I am new to Spring Data REST project and I am trying to create my first RESTful service. The task is simple, but I am stuck.
I want to perform CRUD operations on a user data stored in an embedded database using RESTful API.
But I cannot figure out…

zavanton
- 1,424
- 2
- 9
- 14
109
votes
5 answers
POSTing a @OneToMany sub-resource association in Spring Data REST
Currently I have a Spring Boot application using Spring Data REST. I have a domain entity Post which has the @OneToMany relationship to another domain entity, Comment. These classes are structured as follows:
Post.java:
@Entity
public class Post {
…

ccampo
- 1,483
- 3
- 12
- 14
101
votes
3 answers
Spring Data Rest - Sort by multiple properties
I have an entity as below
Class Person{
String id;
String name;
String numberOfHands;
}
With Spring Data Rest (Gosling Release Train), I'm able to specify
localhost/Person?sort=name,asc
for sorting name name ascending. Now, in a case where I need…

rakpan
- 2,773
- 4
- 26
- 36
97
votes
4 answers
When to use @RestController vs @RepositoryRestResource
I have been looking at various examples of how to use Spring with REST. Our end target is a Spring HATEOAS/HAL setup
I have seen two distinct methods for rendering REST within Spring
Via @RestController within a Controller
Via…

code
- 4,073
- 3
- 27
- 47
81
votes
13 answers
How to map Page to Page in spring-data-rest
When I hit the database with PagingAndSortingRepository.findAll(Pageable) I get Page. However, I want to expose DTO's to the client and not entities. I can create DTO just by injecting entity into it's constructor, but how do I map the…

Tuomas Toivonen
- 21,690
- 47
- 129
- 225
72
votes
2 answers
kotlin data class + bean validation jsr 303
I'm trying to get Kotlin working with jsr 303 validation on a spring-data-rest project.
Given the following data class declarartion :
@Entity data class User(
@Id
@GeneratedValue(strategy = javax.persistence.GenerationType.AUTO)
var…

pellenberger
- 813
- 1
- 6
- 7
61
votes
5 answers
Spring Data Rest and Cors
I am developing a Spring Boot application with a Rest interface and a dart fronted.
The XMLHttpRequest does execute a OPTIONS request which is handled totally correct. After this, the final GET ("/products") request is issued and fails:
No…

Thomas Letsch
- 930
- 1
- 8
- 15
56
votes
12 answers
How to use Spring managed Hibernate interceptors in Spring Boot?
Is it possible to integrate Spring managed Hibernate interceptors (http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html/ch14.html) in Spring Boot?
I'm using Spring Data JPA and Spring Data REST and need an Hibernate interceptor to act on an…

Marcel Overdijk
- 11,041
- 17
- 71
- 110
53
votes
5 answers
Spring Scheduling - Cron expression for everyday at midnight not working?
I am trying to schedule a task in Spring which is to be run everyday at midnight. I followed the official guide from Spring and made the scheduler class as below:
@Component
public class OverduePaymentScheduler {
@Scheduled(cron = "0 0 0 * *…

Charlie
- 3,113
- 3
- 38
- 60
52
votes
6 answers
How to consume Page response using Spring RestTemplate
I'm using spring data (mongoDb) and I've got my repository:
public interface StoriesRepository extends PagingAndSortingRepository {}
Then i have a controller:
@RequestMapping(method = RequestMethod.GET)
public…

bgalek
- 553
- 1
- 5
- 7
48
votes
3 answers
Disable Hypertext Application Language (HAL) in JSON?
Using Spring Data REST with JPA in version 2.0.2.RELEASE.
How can I disable Hypertext Application Language (HAL) in the JSON ? http://stateless.co/hal_specification.html
I have tried many things already, but to no avail. For example, I have set…

jplandrain
- 2,278
- 4
- 24
- 24
48
votes
2 answers
Using @Version in spring-data project
I've been working on a RESTful webservice with spring-data. A few days ago a special spring-data jpa REST framework was released.
Now I noticed the ability to use @Version with this framework. Is this version generated by itself or do you need to do…

Byron Voorbach
- 4,365
- 5
- 27
- 35
46
votes
5 answers
Is it problematic that Spring Data REST exposes entities via REST resources without using DTOs?
In my limited experience, I've been told repeatedly that you should not pass around entities to the front end or via rest, but instead to use a DTO.
Doesn't Spring Data Rest do exactly this? I've looked briefly into projections, but those seem to…

chartle
- 469
- 1
- 5
- 4
46
votes
3 answers
Spring HATEOAS versus Spring Data Rest
Question is, what's the difference between Spring HATEOAS versus Spring Data Rest ?
I feel both can do the same, and Spring Data Rest (as part of Spring Data) seems a bit more…

HighTML
- 613
- 1
- 6
- 12
45
votes
1 answer
Creating multiple aliases for the same QueryDSL path in Spring Data
I have a generic Spring Data repository interface that extends QuerydslBinderCustomizer, allowing me to customize the query execution. I am trying to extend the basic equality testing built into the default repository implementation, so that I can…

woemler
- 7,089
- 7
- 48
- 67