spring-data-rest

Spring Data Rest Ambiguous Association Exception

我们两清 提交于 2019-12-10 03:10:54
问题 The newly added LinkCollectingAssociationHandler is throwing a MappingException due to an ambiguous association in my domain class. The links array looks like this: [<http://localhost:8080/rooms/2/roomGroups>;rel="roomGroups", <http://localhost:8080/rooms/2/userGroup>;rel="userGroup", <http://localhost:8080/rooms/2/room>;rel="room", <http://localhost:8080/rooms/2/originatingConferences>;rel="originatingConferences", <http://localhost:8080/rooms/2/user>;rel="user"] And it is trying to add

Does Spring Data REST support JPA @Version?

心不动则不痛 提交于 2019-12-10 03:04:10
问题 Can I use JPA @Version with Spring Data REST? In Spring Data REST 1.1.0.M1 I can configure the repo exporter to expose the entity ID, which as it happens also exposes @Version -annotated fields. So I thought that if I tried to PUT an entity with some old version number, I'd get the OptimisticLockException . But that doesn't occur. Instead the PUT succeeds (including data updates), except that the version number is always strictly incremented instead of being whatever old version I set it to.

Spring JPA REST One to Many

荒凉一梦 提交于 2019-12-10 02:44:57
问题 I wanted to extend the example Accessing JPA Data with REST by adding an address list to the Person entity. So, I added a list addresses with @OneToMany annotation: @Entity public class Person { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String firstName; private String lastName; @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL) private List<Address> addresses = new ArrayList<>(); // get and set methods... } The Address class is a very simple one

Adding more information to the HATEOAS response in Spring Boot Data Rest

假如想象 提交于 2019-12-09 19:17:42
问题 I have the following REST controller. @RepositoryRestController @RequestMapping(value = "/booksCustom") public class BooksController extends ResourceSupport { @Autowired public BooksService booksService; @Autowired private PagedResourcesAssembler<Books> booksAssembler; @RequestMapping("/search") public HttpEntity<PagedResources<Resource<Books>>> search(@RequestParam(value = "q", required = false) String query, @PageableDefault(page = 0, size = 20) Pageable pageable) { pageable = new

How can I simply add a link to a Spring Data REST Entity

那年仲夏 提交于 2019-12-09 15:59:00
问题 I have my Entities with Spring Data JPA, but to generate stats about them, I use jOOQ in a Spring @Repository . Since my methods return either a List of entities, or a Double , how can I expose them as links? Let's say I have a User entity, I want to get the following JSON: { "_embedded" : { "users" : [ ] }, "_links" : { "self" : { "href" : "http://localhost:8080/api/users" }, "stats" : { "href" : "http://localhost:8080/api/users/stats" } "profile" : { "href" : "http://localhost:8080/api

How to manage REST API versioning with spring data rest?

若如初见. 提交于 2019-12-09 13:11:31
问题 What is the way to go supporting API versioning in Spring Rest Data? Is it possible to do it with repository-resources or do I have to use RepositoryRestController instead? I cannot find anything about API versioning in the oficial site of Spring Rest Data I found a Joshua Long presentations about REST APIs with Spring API versions can be implemented with one of two ways: Through API URIs: https://api.foo.com/v1 Through media types: application/vnd.company.urapp-v3+json The first approach

Spring Data REST - How to include calculated data in a projection?

走远了吗. 提交于 2019-12-09 12:13:41
问题 I have the following domain classes defined. Loan Class @Data @Entity public class Loan { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String loanTitle; @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn(name = "loan_id") private List<Allowance> allowances; } Allowance class @Data @Entity public class Allowance { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @ManyToOne private AllowanceType allowanceType;

How to properly add an element to a collection using JSONPatch with Spring Data REST?

自闭症网瘾萝莉.ら 提交于 2019-12-09 06:32:20
问题 I have a very simple Spring Data REST project with two entities, Account and AccountEmail. There's a repository for Account, but not for AccountEmail. Account has a @OneToMany relationship with AccountEmail, and there is no backlink from AccountEmail. Update: I believe this to be a bug. Filed as DATAREST-781 on Spring JIRA. I included a demo project and instructions to duplicate there. I can create an Account using the following call: $ curl -X POST \ -H "Content-Type: application/json" \ -d

Exposing link on collection entity in spring data REST

你离开我真会死。 提交于 2019-12-08 22:22:30
问题 Using spring data REST I have exposed a ProjectRepository that supports listing projects and performing CRUD operations on them. When I go to http://localhost:8080/projects/ I get the list of projects as I expect. What I am trying to do is add a custom action to the _links section of the JSON response for the Project Collection. For example, I'd like the call to http://localhost:8080/projects/ to return something like this: { "_links" : { "self" : { "href" : "http://localhost:8080/projects/{

Error while updating data using Springboot data rest and OpenJPA

雨燕双飞 提交于 2019-12-08 21:07:31
I am working on Springboot data rest with OpenJPA application, but getting the below exception: RepositoryRestExceptionHandler : Cannot cast org.apache.openjpa.util.LongId to java.lang.Long java.lang.ClassCastException: Cannot cast org.apache.openjpa.util.LongId to java.lang.Long Below is the entity class: Station.java @Entity @Table(name = "STATION") public class Station extends GenericEntityModel<Long> { @Id @SequenceGenerator(name="STATION_SEQ_GEN", sequenceName="STATION_SEQ_GEN", allocationSize = 1) @GeneratedValue(strategy = GenerationType.SEQUENCE, generator="STATION_SEQ_GEN") @Column