spring-data-rest

Spring Data Rest ManytoMany POST

て烟熏妆下的殇ゞ 提交于 2019-12-20 23:23:05
问题 First, let me explain my usecase. It's pretty straight forward. There is a User entity and a Service entity. I have ManytoMany association between User and Service using UserService as the Joined entity (joined table) Initially,there will be some set of users and some set of services. Users can subscribe to any Service at any point of time. In that case, an entry will be added to UserService. But, I am getting null pointer exception when i tried to create a new UserService association. I

Using Spring Security ACL with Spring Data REST

孤者浪人 提交于 2019-12-20 08:38:55
问题 I am trying to authorize apis exposed by Spring Data REST. So far I am able to do role-based authorization i.e: @RepositoryRestResource(path = "book") public interface BookRepository extends JpaRepository<Book, Long> { @PreAuthorize("hasRole('ROLE_ADMIN')") <S extends Book> Book save(Book book); } Also in the same project i have a service layer with ACL mechanism, which is working. I am unable to use PostFilter expression with Spring Data REST i.e: @PostFilter("hasPermission(filterObject,

Spring Data REST cannot post data to REST api

你。 提交于 2019-12-20 05:18:11
问题 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

Spring Data JPA - Get All Unique Values in Column

核能气质少年 提交于 2019-12-19 16:35:41
问题 I have a project using Spring Data JPA that consumes data from a table full of addresses. One of the columns of this table is the city. I would like to get a distinct list of cities that are in the table i.e. SELECT DISTINCT city FROM address . Is there a way to do this using Spring Data JPA? 回答1: This can be achieved using the @Query annotation as: public interface AddressRepository extends CrudRepository<Address, Long> { @Query("SELECT DISTINCT a.city FROM Address a") List<String>

How can I change Jacksons Configuration when using Spring Data REST?

本秂侑毒 提交于 2019-12-19 12:43:08
问题 I'm trying to configure Jackson to show JSR 310 instants in ISO 8601 format. @Configuration class Jackson { @Bean static ObjectMapper objectMapper() { ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules(); objectMapper.disable( SerializationFeature.WRITE_DATES_AS_TIMESTAMPS ); return objectMapper; } } However this is not a unique Bean, and realistically I only would like to disable this one setting. So I'm not really wanting to create ObjectMapper, so much as specify a

Unable to retrieve Spring HATEOAS embedded resource object in case of @ManytoMany relationship and lookup table with extra column

南笙酒味 提交于 2019-12-19 10:17:15
问题 I am unable to retrieve embedded .I am using Spring boot ,spring data rest and spring JPA. I have 3 tables in data base user competency user_competency (join/composite table with extra column) User @Entity @Table(name = "\"user\"", schema = "public") @JsonIdentityInfo( generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "userId") public class User implements java.io.Serializable { private Long userId; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name =

Spring Boot's TestRestTemplate with HATEOAS PagedResources

半世苍凉 提交于 2019-12-19 09:05:30
问题 I'm trying to use the TestRestTemplate in my Spring Boot Application's Integration-Test, to make a request to a Spring Data REST Repository. The response in the browser has the form: { "links": [ { "rel": "self", "href": "http://localhost:8080/apiv1/data/users" }, { "rel": "profile", "href": "http://localhost:8080/apiv1/data/profile/users" }, { "rel": "search", "href": "http://localhost:8080/apiv1/data/users/search" } ], "content": [ { "username": "admin", "enabled": true, "firstName": null,

Two Maven Dependency for latest and old version conflicts

吃可爱长大的小学妹 提交于 2019-12-19 00:16:30
问题 Am using spring-data-dynamoDB project from here, as per its pom.xml they have used 1.6.9.1 version of aws-java-sdk , but I need to use latest version of aws-java-sdk for my project for using some of its features to implement Amazon s3 too. If I include its dependency, <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk</artifactId> <version>1.7.9</version> </dependency> am getting an exception as follows, 12:51:25.298 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory -

Optionally disable HATEOAS format in Spring Data Rest

雨燕双飞 提交于 2019-12-18 18:52:08
问题 So let's say I have an existing application that has two endpoints /people and /pants. Calling GET /people returns: [ { "name":"john", "age":37, "pants":[ { "color":"green", "brand":"levis", "size":"medium" }, { "color":"indigo", "brand":"jncos", "size":"medium-with-huge-legs" } ] }, { "name":"june", "age":23, "pants":[ { "color":"pink", "brand":"gap", "size":"small" } ] } ] If i were to use Spring Data Rest and call GET /person i'd receive something like: { "_links":{ "next":{ "href":"http:/

Spring Data Rest controllers: behaviour and usage of @BasePathAwareController, @RepositoryRestController, @Controller and @RestController

主宰稳场 提交于 2019-12-18 14:53:57
问题 I'm trying to understand the exact behaviour of the Spring Data Rest Controllers. I have made a simple implementation to test 4 kinds of annotated controllers: @BasePathAwareController , @RepositoryRestController , @RestController , @Controller The controller has a mapping for an entity "author" in the repository. This is the controller: @BasePathAwareController //@RepositoryRestController //@RestController //@Controller public class MyController { @RequestMapping(value="authors/mycontroller