spring-data-rest

Spring Data REST - Exception when PATCH is sent with an empty array in request body

岁酱吖の 提交于 2020-01-06 01:30:05
问题 I am using Spring Data REST and I have the following entities in my domain. Atoll.class @Entity @Data public class Atoll { @Id @GeneratedValue private Long id; private String atollName; @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) @JoinColumn(name = "atoll_id") private List<Island> islands = new ArrayList<>(); } Island.class @Entity @Getter @Setter public class Island extends Auditable{ @Id @GeneratedValue private Long id; private String islandName; @Override public boolean

How to improve error responses when using @RepositoryRestResource

孤人 提交于 2020-01-05 05:32:04
问题 I'm using spring's @RepositoryRestResource annotation on a PagingAndSortingRepository . When I send an erroneous payload to the corresponding endpoint, the error responses that are sent back are hard to parse, e.g. { "cause": { "cause": { "cause": null, "message": "ERROR: duplicate key value violates unique constraint \"uk_bawli8xm92f30ei6x9p3h8eju\"\n Detail: Key (email)=(jhunstone0@netlog.com) already exists." }, "message": "could not execute statement" }, "message": "could not execute

Spring Data-Rest POST to sub-resource

☆樱花仙子☆ 提交于 2020-01-04 23:06:23
问题 Lets say I have the following structure: @Entity class Person extends AbstractPersistable<Long> { String name String surname } @Entity class Task extends AbstractPersistable<Long> { String description @ManyToOne Person person } If I follow proper HAL guidelines I'm not supposed to expose entity id's. Since I don't have a bi-directional relationship I cant PUT or PATCH to http://localhost:8080/persons . Even if I did create the relation, I probably wouldn't want to first POST the Task to

Spring Data-Rest POST to sub-resource

梦想与她 提交于 2020-01-04 23:06:21
问题 Lets say I have the following structure: @Entity class Person extends AbstractPersistable<Long> { String name String surname } @Entity class Task extends AbstractPersistable<Long> { String description @ManyToOne Person person } If I follow proper HAL guidelines I'm not supposed to expose entity id's. Since I don't have a bi-directional relationship I cant PUT or PATCH to http://localhost:8080/persons . Even if I did create the relation, I probably wouldn't want to first POST the Task to

Spring Data Rest Jpa insert @Lob field

若如初见. 提交于 2020-01-04 09:37:26
问题 I have a spring data rest service, that expose a resource like: @Entity public class Resource{ private String name; @Lob private byte[] data; private String contentType; } How should be a json to insert a resource of this type? 回答1: AFAIK, SDR does not handle multipart requests or responses yet, as it can only do JSON. You can run SDR at the same time as a regular Spring MVC servlet (it's one line of code in your config). I would suggest using a regular Spring MVC controller for your file

Spring Data Rest Jpa insert @Lob field

﹥>﹥吖頭↗ 提交于 2020-01-04 09:37:25
问题 I have a spring data rest service, that expose a resource like: @Entity public class Resource{ private String name; @Lob private byte[] data; private String contentType; } How should be a json to insert a resource of this type? 回答1: AFAIK, SDR does not handle multipart requests or responses yet, as it can only do JSON. You can run SDR at the same time as a regular Spring MVC servlet (it's one line of code in your config). I would suggest using a regular Spring MVC controller for your file

Enable repository only for sub resource level in spring data rest?

人盡茶涼 提交于 2020-01-04 06:05:32
问题 I have 2 jpa entities Document and DispatchDetail which have one-to-many relationship. i.e. a document can have a list of dispatchDetails. I have created 2 repositories for each entity. Now I'm gonna try a document GET. http://localhost:7070/booking-documents-service/docs/5999571 { "docType": "SAP_ACCOUNTS_PAYABLE", "docStoreId": 456651, "qualityChecked": true, "format": "pdf", "bookingId": -1, "_links": { "self": { "href": "http://localhost:7070/booking-documents-service/docs/5999571" },

Enable repository only for sub resource level in spring data rest?

巧了我就是萌 提交于 2020-01-04 06:05:28
问题 I have 2 jpa entities Document and DispatchDetail which have one-to-many relationship. i.e. a document can have a list of dispatchDetails. I have created 2 repositories for each entity. Now I'm gonna try a document GET. http://localhost:7070/booking-documents-service/docs/5999571 { "docType": "SAP_ACCOUNTS_PAYABLE", "docStoreId": 456651, "qualityChecked": true, "format": "pdf", "bookingId": -1, "_links": { "self": { "href": "http://localhost:7070/booking-documents-service/docs/5999571" },

Default Sort on a Spring Data JPA Repository Method with Custom Query and Pageable Parameter

北城以北 提交于 2020-01-03 19:20:21
问题 I have the following repository method that works exactly the way I need it to iff the user provides a sort column in the page parameter: public interface IdentityRepository extends JpaRepository<Identity, String> { @Query("select distinct ident from Identity ident left outer join ident.authorities authority " + "where (" + "(:src is null or ident.source = :src) and " + "(:org is null or ident.organization = :org) and " + "(:auth is null or authority.authority = :auth) and " + "(:authSrc is

Default Sort on a Spring Data JPA Repository Method with Custom Query and Pageable Parameter

夙愿已清 提交于 2020-01-03 19:18:14
问题 I have the following repository method that works exactly the way I need it to iff the user provides a sort column in the page parameter: public interface IdentityRepository extends JpaRepository<Identity, String> { @Query("select distinct ident from Identity ident left outer join ident.authorities authority " + "where (" + "(:src is null or ident.source = :src) and " + "(:org is null or ident.organization = :org) and " + "(:auth is null or authority.authority = :auth) and " + "(:authSrc is