spring-data-rest

adding association links to spring data rest custom exposed method

六月ゝ 毕业季﹏ 提交于 2019-12-06 05:51:56
Hi I have exposed a custom @RepositoryRestController to expose a custom method via Spring data rest the code for the method looks something like below @RequestMapping(method = RequestMethod.GET, value = "/foo/rsqlsearch") public @ResponseBody PagedResources<Resource<Foos>> findAllPaged(@RequestParam(value = "rsql") String rsql, Pageable pageable) { Page<Foo> foos= fundRepository.searchByRsql(rsql, pageable); return pagedResourcesAssembler.toResource(foos); } foo entity @Entity @Table(name = "FOO_TBL", schema = "F") @Data public class Foo implements Identifiable<String> { @Id @Column(name = "ID

Spring returns Resource in pure JSON not in HAL Format when including spring data rest

三世轮回 提交于 2019-12-06 05:18:38
问题 When I use the default controller for my Entities, provided by Spring Data Rest everything works like it should. The output looks like this: { "_links" : { "search" : { "href" : "http://localhost:8080/users/search" } }, "_embedded" : { "users" : [ { "firstName" : "Max", "lastName" : "Mustermann", "email" : "mail@max-mustermann.de", "_links" : { "self" : { "href" : "http://localhost:8080/users/myadmin" } } } ] } } But if I use my own Controller the output looks like this: [ { "firstName" :

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

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 05:07:44
问题 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

Spring Data REST: “no String-argument constructor/factory method to deserialize from String value”

允我心安 提交于 2019-12-06 04:40:51
问题 When I use Lombok in my Spring Data REST application to define complex types like: @NoArgsConstructor @AllArgsConstructor @Data @Entity @Table(name = "BOOK") public class Book { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(nullable = false) private Long id; private String title; @ManyToOne(cascade = {CascadeType.DETACH, CascadeType.MERGE, CascadeType.REFRESH}) private Person author; // ... } with a Spring Data REST controllers like: @RepositoryRestController public class

Spring Data Rest - PUT is not working for associated reference types?

只谈情不闲聊 提交于 2019-12-06 04:23:24
I have the following domain class implemented for a Spring Data Rest project. @Entity @Data public class Address { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private long addressID; private String houseName; private String apartmentNumber; @ManyToOne private City city; @ManyToOne private Country country; } Now I am creating an Address resource by sending a POST with following JSON. { "houseName":"Some House", "apartmentNumber":"13 B", "city": "http://localhost:8080/city/1" "country":"http://localhost:8080/countries/1" } When I send a PUT request to the

Feign and HAL/resources

二次信任 提交于 2019-12-06 04:14:55
问题 I've got a server that exposes resources through spring-data-rest and this uses, as far as I understand HAL or HATEOAS. But when I try to use it in combination with Feign, I can't seem to be able to register a Jackson2HalModule that gets picked up. Is there something I have to do to connect the Feign "client" to the new converter? Does it use another ObjectMapper than the one I got here? Code: @Inject public void configureObjectMapper(ObjectMapper mapper, RestTemplate template) { mapper

Spring Data Rest Repository with abstract class / inheritance

北慕城南 提交于 2019-12-06 03:45:41
问题 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;

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

江枫思渺然 提交于 2019-12-06 03:15:54
问题 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

javax.persistence.RollbackException: Error while committing the transaction] with root cause java.lang.StackOverflowError: null

江枫思渺然 提交于 2019-12-05 22:08:05
I have a Spring Boot API using the Spring Data REST framework (dependencies inherited from spring-boot-starter-parent 2.1.0.RELEASE). I'm attempting to do a PUT or PATCH request to update an entity and neither seem to work, throwing the following error message: [Request processing failed; nested exception is org.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction] with root cause java.lang.StackOverflowError: null The entity I am trying to update has the

Spring Data Rest Custom Links on Resource

早过忘川 提交于 2019-12-05 21:14:50
The Spring Data Rest repository notes that Custom Links can be added to an Entity as below: http://docs.spring.io/spring-data/rest/docs/current/reference/html/#_the_resourceprocessor_interface Example Given: @Bean public ResourceProcessor<Resource<Person>> personProcessor() { return new ResourceProcessor<Resource<Person>>() { @Override public Resource<Person> process(Resource<Person> resource) { resource.add(new Link("http://localhost:8080/people", "added-link")); return resource; } }; } Obviously hard coding is bad so how do I write such component that can dynamically get the path for another