spring-data-rest

Enable HAL serialization in Spring Boot for custom controller method

对着背影说爱祢 提交于 2019-11-26 09:40:01
问题 I\'m trying to build a RESTful API with Spring Boot using spring-boot-starter-data-rest. There are some entities: accounts, transactions, categories and users - just the usual stuff. When I retrieve the objects at http://localhost:8080/transactions via the API that has been generated by default, all is going well an I get a list with all transactions as JSON objects like that one: { \"amount\": -4.81, \"date\": \"2014-06-17T21:18:00.000+0000\", \"description\": \"Pizza\", \"_links\": { \"self

While using Spring Data Rest after migrating an app to Spring Boot, I have observed that entity properties with @Id are no longer marshalled to JSON

老子叫甜甜 提交于 2019-11-26 08:25:47
问题 This question is related to this SO question (Spring boot @ResponseBody doesn't serialize entity id). I have observed that after migrating an app to Spring Boot and using the spring-boot-starter-data-rest dependency, my entity @Id fields are no longer marshalled in the resulting JSON. This is my request mapping and while debugging, I can see the data isn\'t being changed prior to returning it, so the @Id properties are being stripped later on. @RequestMapping(method = RequestMethod.GET,

How to use Spring managed Hibernate interceptors in Spring Boot?

心不动则不痛 提交于 2019-11-26 07:28:25
问题 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 update of a particular field on an entity. With standard JPA events it\'s not possible to get the old values, and hence I think I need to use the Hibernate interceptor. 回答1: There's not a particularly easy way to add a Hibernate interceptor that is

POSTing a @OneToMany sub-resource association in Spring Data REST

坚强是说给别人听的谎言 提交于 2019-11-26 05:50:56
问题 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 { @Id @GeneratedValue private long id; private String author; private String content; private String title; @OneToMany private List<Comment> comments; // Standard getters and setters... } Comment.java: @Entity public class Comment { @Id

How to maintain bi-directional relationships with Spring Data REST and JPA?

一笑奈何 提交于 2019-11-26 05:27:34
问题 Working with Spring Data REST, if you have a OneToMany or ManyToOne relationship, the PUT operation returns 200 on the \"non-owning\" entity but does not actually persist the joined resource. Example Entities: @Entity(name = \'author\') @ToString class AuthorEntity implements Author { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) Long id String fullName @ManyToMany(mappedBy = \'authors\') Set<BookEntity> books } @Entity(name = \'book\') @EqualsAndHashCode class BookEntity implements

Disable Hypertext Application Language (HAL) in JSON?

拜拜、爱过 提交于 2019-11-26 05:24:56
问题 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 Accept and Content-type headers to \"application/json\" instead of \"application/hal+json\" but I still receive the JSON content with hyper links. For example, I\'d like to get something like: { \"name\" : \"Foo\", \"street\" : \"street Bar\", \

Spring Data Rest and Cors

强颜欢笑 提交于 2019-11-26 01:47:08
问题 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 \'Access-Control-Allow-Origin\' header is present on the requested resource. Origin \'http://localhost:63343\' is therefore not allowed access. After some debugging I have found the following: The AbstractHandlerMapping.corsConfiguration is populated for

Spring Data Rest and Cors

你说的曾经没有我的故事 提交于 2019-11-25 21:04:58
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 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://localhost:63343 ' is therefore not allowed access. After some debugging I have found the following: The AbstractHandlerMapping.corsConfiguration is populated for all Subclasses except RepositoryRestHandlerMapping. In the RepositoryRestHandlerMapping no