spring-data-rest

using validators in spring-data-rest returns http 500 instead of 400

杀马特。学长 韩版系。学妹 提交于 2019-12-04 11:05:35
问题 I'm trying to get the validation in spring-data-rest to work. From the documentation you only need to make a validator available, and I've got that to work, but when a validation constraint is successfully caught/processed I get a 500 error page with the stack trace. In the config class, RepositoryRestMvcConfiguration it has a validationExceptionHandler which looks like it should get such validation errors to return as 400 rather than 500. It is also a lazy loaded bean. Do I have an incorrect

How to disallow PUT while allowing POST and PATCH in Spring Data REST?

独自空忆成欢 提交于 2019-12-04 10:25:40
Is it possible to completely disallow PUT for a repository in Spring Data REST while POST on the collection and PATCH on the item remain possible? The rationale behind this is that a PUT typically allows for replace semantics, but in our case the resource can only be created via POST on the collection, partially updated via PATCH on the item (using specific UI dialogs... each of which only supports a particular partial update), or deleted via DELETE on the item. If you have Spring security in your application, then this can be done by adding intercept-url to deny access to PUT method on Spring

spring.data.rest.max-page-size does not seem to work?

 ̄綄美尐妖づ 提交于 2019-12-04 10:06:32
Under Boot 1.3.0.M5 i use in application.properties spring.data.rest.max-page-size=10 But i still can set the size to 40 in a URL and get a correct response. For example : http://localhost:8080/cine20-spring/api/films?page=0&size=40&sort=title,asc will give me back 40 films So what is the use of this parameter ? Update test with Spring-Boot 1.4.2 There is still a problem : By default WITHOUT the dependencies spring-boot-starter-data-rest , the max-page-size is set to 2000 by default and changing the max-page-size value won't work : spring.data.rest.max-page-size=0x7fffffff does not work.

Accepting a Spring Data REST URI in custom controller

非 Y 不嫁゛ 提交于 2019-12-04 10:03:15
问题 I have a Spring Data Rest webmvc application that I'd like to add some custom functionality to for batch operations. I've created a controller, and blended it into the uri namespace, but I'd like for it to be able to accept URI's like the custom /search queries do, rather than simply an ID. I have tried registering a custom <String, Long> converter (my entity has a Long ID type, but that seems to get ignored. Is there any way to configure my controller such that it adopts that behavior from

How to avoid N+1 queries with Spring Data REST Projections?

孤街醉人 提交于 2019-12-04 09:41:07
问题 I have been prototyping my new application in Spring Data REST backed by Spring Data JPA & Hibernate, which has been a fantastic productivity booster for my team, but as the data model becomes more complex the performance is going down the tubes. Looking at the executed SQL, I see two separate but related problems: When using a Projection with only a few properties to reduce the size of my payload, SDR is still loading the entire entity graph, with all the overhead that incurs. EDIT: filed

Spring Data Rest Repository with abstract class / inheritance

ε祈祈猫儿з 提交于 2019-12-04 09:02:49
I can't get Spring Data Rest with class inheritance working. I'd like to have a single JSON Endpoint which handles all my concrete classes. Repo: public interface AbstractFooRepo extends KeyValueRepository<AbstractFoo, String> {} Abstract class: @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") @JsonSubTypes({ @JsonSubTypes.Type(value = MyFoo.class, name = "MY_FOO") }) public abstract class AbstractFoo { @Id public String id; public String type; } Concrete class: public class MyFoo extends AbstractFoo { } Now when calling POST /abstractFoos with {

Spring Data Rest : How to expose custom rest controller method in the HAL Browser

会有一股神秘感。 提交于 2019-12-04 08:13:56
i have created a custom rest controller and I can access the API and get the result from the resource, the problem is, it doesn't appear in the HAL Browser.. how to expose this custom method in the HAL Browser? Thank You... @RepositoryRestController public class RevisionController { protected static final Logger LOG = LoggerFactory .getLogger(RevisionController.class); private final DisciplineRepository repository; Function<Revision<Integer, Discipline>, Discipline> functionDiscipline = new Function<Revision<Integer, Discipline>, Discipline>() { @Override public Discipline apply(Revision

Spring Data Rest Custom Controller

泄露秘密 提交于 2019-12-04 06:43:53
I have requirement where in which i need to override the delete functionality from the rest Resource using a custom controller.here is the code for restResource @RepositoryRestResource public interface SampleRepository extends JpaRepository<Sample,Long>{ List<Sample> findBySampleNumber(@Param("sampleNumber") String sampleNumber); } i have created a a custom controller which overides only delete fuctionality @RepositoryRestController @RequestMapping("/api/samples") public class SampleController{ @Autowired SampleRepository sampleRepository; @RequestMapping(value = "/{id}", method =

Unable to save data to composite Table Via Spring Data rest json post

吃可爱长大的小学妹 提交于 2019-12-04 05:29:30
问题 I have 3 Tables in db training - training_id (pk) user_profile - profile_id (pk) -training_profile (composite table) - training_id - profile_id I have already record in user_profile table having profile_id=44 and want to create new record for training table ,and also to associate this new training with already existing user_profile record which has id 44,but after post data is saved to training table but it is not inserted into lookup table user_training. My Object Classes Are - Training

How do I avoid content fields in Joda objects?

淺唱寂寞╮ 提交于 2019-12-04 04:21:20
问题 I'm using Joda objects (DateTime and DateTimeZone) in a document and whenever I access it via the REST interface I get entries with fields like this lastAggregationDate: { content: "2016-07-12T17:58:43.643Z" } instead of lastAggregationDate: "2016-07-12T17:58:43.643Z" I have the Joda Jackson dependencies declared and I see the de/serializers for these types so I'm puzzled as to what's at work here. I've duplicated this behavior in a slightly modified Spring sample project but using Java's