spring-data-rest

Spring Data REST cannot post data to REST api

梦想与她 提交于 2019-12-02 04:19:43
When I try to post data to my REST API (created using Spring DATA JPA REST) using this command: curl -g -i -X POST -H "Content-Type:application/json" -d '{ "profilphotoid" : 1 }' http://localhost:8080/users/ I get this error: 2016-04-26 04:51:44.288 ERROR 10808 --- [nio-8080-exec-8] o.s.d.r.w.RepositoryRestExceptionHandler : Could not read document: Unexpected character (''' (code 39)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [Source: org.apache.catalina.connector.CoyoteInputStream@46929f6b; line: 1, column: 2]; nested exception is com.fasterxml

Calling spring data rest repository method doesn't return links

大兔子大兔子 提交于 2019-12-02 02:41:49
问题 I have the repository "ClientRepository": public interface ClientRepository extends PagingAndSortingRepository<Client, Long> { } When i request http://localhost:8080/clients/1 then server responds { "algorithmId" : 1, "lastNameTxt" : "***", "firstNameTxt" : "**", "middleNameTxt" : "**", "_links" : { "self" : { "href" : "http://localhost:8080/clients/1121495168" }, "client" : { "href" : "http://localhost:8080/clients/1121495168" } } } Response has links as expected. When i call repository

inconsistent org.joda.time.DateTime serialization result when Spring Boot from 1.3.X to 1.4.0

天大地大妈咪最大 提交于 2019-12-02 02:22:15
After upgrading a Spring Boot upgrade from 1.3.3 to 1.4.0, I have noticed a change of behavior when serializing a org.joda.time.DateTime. Let's build up a simple Spring boot + Maven Project. The pom.xml dependencies: <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.7.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data

Spring data rest status 500 for entity with relation

不羁的心 提交于 2019-12-02 01:59:30
问题 I have two entities with a relation one to many public class Order { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String userName; private String company; @OneToMany(cascade={CascadeType.PERSIST, CascadeType.MERGE}) @JoinColumn(name="ORDER_ID") private List<Item> items; } public class Item { @Id @GeneratedValue(strategy=GenerationType.AUTO) private Long id; private String name; private Long quantity; } Both entities have a @RepositoryRestResrouce and when I try

inconsistent org.joda.time.DateTime serialization result when Spring Boot from 1.3.X to 1.4.0

我只是一个虾纸丫 提交于 2019-12-02 01:51:00
问题 After upgrading a Spring Boot upgrade from 1.3.3 to 1.4.0, I have noticed a change of behavior when serializing a org.joda.time.DateTime. Let's build up a simple Spring boot + Maven Project. The pom.xml dependencies: <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.7.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> <

Calling spring data rest repository method doesn't return links

↘锁芯ラ 提交于 2019-12-02 01:08:41
I have the repository "ClientRepository": public interface ClientRepository extends PagingAndSortingRepository<Client, Long> { } When i request http://localhost:8080/clients/1 then server responds { "algorithmId" : 1, "lastNameTxt" : "***", "firstNameTxt" : "**", "middleNameTxt" : "**", "_links" : { "self" : { "href" : "http://localhost:8080/clients/1121495168" }, "client" : { "href" : "http://localhost:8080/clients/1121495168" } } } Response has links as expected. When i call repository inherited method findOne in another controller @RestController public class SearchRestController {

How to have PersistentEntityResourceAssembler injected into request methods of custom @RepositoryRestController in a @WebMvcTest unit test

流过昼夜 提交于 2019-12-02 01:00:17
问题 Overview How can I have a PersistentEntityResourceAssembler properly injected into my custom REST controller's request methods during a @WebMvcTest unit test? First SO question. Apologies in advance, probably just missing something stupid. Sample code available on GitHub. Oliver Gierke, where you at? :P Details I have a custom REST controller annotated with @RepositoryRestController . Some of its request methods have a PersistentEntityResourceAssembler injected as an argument so I can return

Spring Data Rest: How to search by another object's key?

二次信任 提交于 2019-12-02 00:34:23
问题 In Spring-Data-Rest an object's ID is the URI returned with the object. For example, if I have a User, it might have a URI like: http://example.com/users/1 In an authentic REST api, this URI is the id of the object, you are not supposed to use just '1' as the id. Give that, how do I search for all Orders that belong to that User? http://example.com/orders/search/findByUser?user={{XXX}} Specifically, what do I use for {{XXX}}? I know I could do the opposite search: http://example.com/users/1

Spring Boot Data Rest + CORS not being enabled properly for OPTIONS/DELETE

浪子不回头ぞ 提交于 2019-12-01 23:03:45
I've got an extremely simple example that I can't get to work. I have my domain that models my database, and my Repository. public interface MyTestRepository extends CrudRepository<MyTest, Integer> { } I used http://resttesttest.com/ to test it. For GET Method's it returns me the JSON REST information without any issue. I can query the endpoint http://localhost:8080/mytest/1 and I get back the information for id=1 from the database. However, the problem comes in when I try to use the DELETE option. If I run a DELETE on http://localhost:8080/mytest/1 I get Response to preflight request doesn't

How do I avoid content fields in Joda objects?

狂风中的少年 提交于 2019-12-01 22:38:21
I'm using Joda objects (DateTime and DateTimeZone) in a document and whenever I access it via the REST interface I get entries with fields like this lastAggregationDate: { content: "2016-07-12T17:58:43.643Z" } instead of lastAggregationDate: "2016-07-12T17:58:43.643Z" I have the Joda Jackson dependencies declared and I see the de/serializers for these types so I'm puzzled as to what's at work here. I've duplicated this behavior in a slightly modified Spring sample project but using Java's native date types rather than Joda's. I've added a date of birth property to the Person object and