spring-data-rest

Spring Rest: Cannot insert rows that have @ManyToOne column

和自甴很熟 提交于 2019-11-29 17:26:57
I am following a spring getting started tutorial in https://spring.io/guides/gs/accessing-data-rest/ I added another entity books that has @ManyToOne relation to Person entity. Person entity has a new property called bikes and has a @OneToMany relation with Bike entity. Only thing that is different from the getting started project is the new attribute with its getter and setter: package hello; import java.util.List; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToMany;

Spring REST LocalDate UTC differs of one day

痞子三分冷 提交于 2019-11-29 16:22:06
I'm using Spring Boot 1.5.4, Hibernate 5.2.10, Spring Data REST, HATEOAS, JDK8 with LocalDate and LocalDateTime. My computer is on CEST timezone but I want the application works in UTC, so I set in application.properties: spring.datasource.url=jdbc:mysql://localhost:3306/database?useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=true spring.jpa.hibernate.jdbc.time_zone = UTC According to this article I don't want to change the timezone of my JVM because seems not to be a best practice. Spring Data REST exposes my repositories and I use Swagger2 to have a nice interface to use API. When I

Creating new entity plus association not working

佐手、 提交于 2019-11-29 15:37:39
I am having two entities AppUser and UserGroup . They have a @ManyToMany relationship. I am currently trying to create and associate a new group for an existing user like this: POST http://localhost:8080/groups { "name": "Group 1", "users": ["http://localhost:8080/users/1"] } The problem is that only the group gets created - but no association with the listed users - and still the server responds with 201 Created ?! These are the two repositories: @RepositoryRestResource(collectionResourceRel = "users", path = "users") public interface AppUserRepository extends JpaRepository<AppUser, Long> {

Spring Boot (JAR) with multiple dispatcher servlets for different REST APIs with Spring Data REST

我怕爱的太早我们不能终老 提交于 2019-11-29 15:28:15
问题 I have a project that uses Spring Boot to generate an executable JAR that exposes a REST API with Spring Data REST. It is also integrated with Spring Security OAuth. That works fine. My problem is the following, I want to have different modules for the REST API that I want to enable only if the correspondent JAR with the JPA repositories is in the classpath (it has been defined as a dependency). The thing is I want them to be independent from each other. I want to be able to serve them under

Spring Data Rest (SDR ) bug? Persistent Entity Must not be null

跟風遠走 提交于 2019-11-29 14:14:11
Currently I am working on a POC for Spring Data Rest. Trying to get workable JSONout of a repository. I have an Entity Class (NewTask) @Entity @Table(name="newtable") public class NewTask { @Id @Column(name="newid") private int id; @Column(name="newage") private int age; @Column(name="newaddress") private String address; public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public int getId() { return id; } public void setId(int id) { this.id = id; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } }

Customizing Param Binding for QueryDSL Support

不问归期 提交于 2019-11-29 12:02:32
I have a Spring Data Rest repository which utilises the QueryDSL support outlined here: https://spring.io/blog/2015/09/04/what-s-new-in-spring-data-release-gosling#spring-data-rest The default is to query all specified parameters using equals. A mechanism to override the param binding to something other than equals is given in the same article however it requires Java 8. https://spring.io/blog/2015/09/04/what-s-new-in-spring-data-release-gosling#querydsl-web-support Is there any clean way in Java 7 to achieve the same functionality? Update I can get the binding customization working as below:

Spring Data REST - Consume List of Entities, Java HATEOAS client

元气小坏坏 提交于 2019-11-29 11:41:24
I'm using Spring Data REST 2.5.1, Jackson 2.8.0, Spring Boot 1.3.6. I'm trying to retrieve a simple list of entities from my Repository via RestTemplate. I can hit the end point in a browser, and get the expected HAL data. Retrieving a single Entity works fine as below. These are all using the default SDR endpoints (e.g. localhost:{port}/myEntity). ResponseEntity<Resource<MyEntity>> responseEntity = new RestTemplate() .exchange( uri + "/1", HttpMethod.GET, HttpEntity.EMPTY, new ParameterizedTypeReference<Resource<MyEntity>>() {}, port ) Or new RestTemplate().getForEntity(uri + "/1", MyEntity

Spring Data Rest 2.0.0.RELEASE Breaks Code Working Previously With RC1

ε祈祈猫儿з 提交于 2019-11-29 11:33:21
I have a project which is utllizing Spring Data Rest. I originally had version 2.0.0.BUILD-SNAPSHOT in my pom.xml, but during my last update the code broke and began throwing the following IllegalStateException when accessing most endpoints: java.lang.IllegalStateException: No suitable resolver for argument [0] [type=org.springframework.http.converter.HttpMessageNotReadableException] HandlerMethod details: Controller [org.springframework.data.rest.webmvc.RepositoryEntityController] Method [public org.springframework.http.ResponseEntity<org.springframework.data.rest.webmvc.support

Modify SQL query generated behind Spring Data REST projections

天涯浪子 提交于 2019-11-29 10:59:10
问题 EDIT : How to Keep only needed columns in SELECT for Spring Data Rest Projections? Spring Data Rest Projections are good for getting a subset of columns for links which are generated, but the Query that gets generated in behind still has all columns in it. How can Projections be created where also SQL queries have only those columns in SELECT which are in Projection 回答1: I don't know why it's missing from the docs, but this spring sample (from spring) shows that you can use projections as the

How to add Custom Interceptor in Spring data rest (spring-data-rest-webmvc 2.3.0)

扶醉桌前 提交于 2019-11-29 10:48:05
I am working on the spring data rest services & facing some issue in the custom interceptors. Earlier I used spring-data-rest-webmvc 2.2.0 & added interceptor in following way. public RequestMappingHandlerMapping repositoryExporterHandlerMapping() { RequestMappingHandlerMapping mapping = super .repositoryExporterHandlerMapping(); mapping.setInterceptors(new Object[] { new MyInterceptor() }); return mapping; } It worked perfectly fine for me. But when i upgraded to spring-data-rest-webmvc 2.3.0 version, I noticed that handlerMapping is hidden behind DelegatingHandlerMapping. Hence I tried to