spring-data-rest

spring-data-rest, can you provide full details of entity instead of (or with) link [duplicate]

痞子三分冷 提交于 2019-12-08 17:03:57
问题 This question already has answers here : Selectively expand associations in Spring Data Rest response (2 answers) Closed 2 years ago . Is there a way to return the full details of a joined entity instead of a link? In the example below I want to also return the details of the product, if I have list of 100 purchases, it would avoid having to make 100 calls to get the product details. The repositories for Product, User and Purchase entities are all created using spring-data-jpa { "_embedded" :

spring-data-rest-webmvc 2.0.0 - RepositoryRestExporterServlet missing

假如想象 提交于 2019-12-08 13:47:30
I'm trying to create a REST web service with spring-data-rest-webmvc 2.0.0. I'm following the handbook "Spring in Practice" where you use the version 1.0.0. In this handbook, it define the exporter servlet in web.xml as below: <web-app ...> ... <servlet> <servlet-name>api</servlet-name> <servlet-class>org.springframework.data.rest.webmvc.RepositoryRestExporterServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>api</servlet-name> <url-pattern>/api/*</url-pattern> </servlet-mapping> </web-app> in version 2.0.0, I can not find the

spring-data-rest and controllers, use the same objectMaper for serializing/deserializing

无人久伴 提交于 2019-12-08 09:52:31
问题 I have found in the documentation of spring-data-rest that it use it's own objectMapper implementation. I would like to know if it's possible to reuse this objectMapper so I can have the same entity representation as in spring-data-rest endpoint For example, without any jackson objectMapper bean I have this Endpoint: GET /api/companies "createdDate": { "content": "2016-12-25T12:39:03.437Z" }, "lastModifiedDate": null, "createdById": null, "lastModifiedById": null, "active": true, "name": "A6"

Customize DELETE method in Spring Data repository

一个人想着一个人 提交于 2019-12-08 09:35:38
问题 For some logging purpose, i'm using AspectJ to log CRUD operations, for the delete operation i'm supporting only repository.delete(object) so repository.delete(id) is not supported, but while using http DELETE call in Spring Data repository, i intercept repository.findOne() then repository.delete(id) calls. My Question How i could customize Http DELETE method in Spring Data repository to call repository.delete(object) not repository.delete(id) . here's repository interface: package com.geopro

Spring Data Rest Override Repositories (Controllers vs AOP)

。_饼干妹妹 提交于 2019-12-08 07:53:06
问题 Domain/Repository Project { User owner; } //Querydsl repositories @RepositoryRestResource public interface ProjectRepository extends PagingAndSortingRepository<Project, Long>, QueryDslPredicateExecutor<Project>, QuerydslBinderCustomizer<QProject> { default void customize(QuerydslBindings bindings, QProject project) { (...) } } Requeriment: filter data according to the authenticated user context: If user is ROLE_PUBLIC show projects according predicate and where user is the owner . If user is

Error while updating data using Springboot data rest and OpenJPA

旧街凉风 提交于 2019-12-08 06:45:45
问题 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",

converting URI to entity with custom controller in spring data rest?

不羁岁月 提交于 2019-12-08 06:42:54
问题 i have an jpa entity like this. @Entity @Table(name = "location") @Data public class Location { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; @Column(name = "LOCATION_ID", unique = true) @NotEmpty(message = "Please Enter Location ID") private String name; @Column(name = "LOCATION_DESCRIPTION") @NotEmpty(message = "Please Enter Location Description") private String description; @ManyToOne @NotNull(message = "Please Choose a Building") Building building; @Version Long

Define sort property for referenced field during order by in JPQL

眉间皱痕 提交于 2019-12-08 06:35:44
问题 I have rest repository with 2 entities and projection: @Entity public class Person { @Id @GeneratedValue private Long id; String name; @ManyToOne Language language; } @Entity public class Language { @Id @GeneratedValue private Long id; private String name; } public interface PersonRepository extends PagingAndSortingRepository<Person, Long> { } @Projection(name = "details", types = {Person.class}) interface PersonProjection { Long getId(); String getName(); @Value("#{target.language.name}")

Implementing/Overriding MongoRepository Keep HATEOAS Formatting

半城伤御伤魂 提交于 2019-12-08 06:22:21
问题 I have a simple MongoRepository I would like to modify to return the generated ObjectId on post(save()). public interface EmployeeRepository extends MongoRepository<Employee, String> { public void delete(Employee employee); public Employee save(Employee employee); public Employee findOne(String id); public List<Employee> findAll(); public Employee findByName(String principal); } I have explored ways to generate the id client side and pass it in the post BUT I really want Spring to handle this

RepositoryRestResource with spring-boot CLI

跟風遠走 提交于 2019-12-08 03:59:55
问题 I'm trying to implement a simple REST service based on a JPA repository with spring-boot and spring-data-rest. (see this tutorial) The following code works quite well if a use it with gradle: package ch.bfh.swos.bookapp import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.context.annotation.* import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration import org.springframework