spring-hateoas

Spring Data REST HATEOS : not lazy loading

≯℡__Kan透↙ 提交于 2021-01-22 05:21:12
问题 Problem I have two entities defined: School and District . A district can have many schools and a school can belong to one district. When executing a GET request against this endpoint http://localhost:8080/districts I would like to get a list of all the districts WITHOUT fetching each district's set of associated schools. But it seems like no matter what I do, hibernate is making DB calls to fetch data for each school individually. Entities School @Getter @Setter @NoArgsConstructor @Entity

How to force Spring HATEOAS resources to render an empty embedded array?

余生长醉 提交于 2020-12-28 07:10:01
问题 I have the following controller method: @RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE, value = "session/{id}/exercises") public ResponseEntity<Resources<Exercise>> exercises(@PathVariable("id") Long id) { Optional<Session> opt = sessionRepository.findWithExercises(id); Set<Exercise> exercises = Sets.newLinkedHashSet(); if (opt.isPresent()) { exercises.addAll(opt.get().getExercises()); } Link link = entityLinks.linkFor(Session.class) .slash(id) .slash(Constants.Rels.EXERCISES)

How to force Spring HATEOAS resources to render an empty embedded array?

…衆ロ難τιáo~ 提交于 2020-12-28 07:02:23
问题 I have the following controller method: @RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE, value = "session/{id}/exercises") public ResponseEntity<Resources<Exercise>> exercises(@PathVariable("id") Long id) { Optional<Session> opt = sessionRepository.findWithExercises(id); Set<Exercise> exercises = Sets.newLinkedHashSet(); if (opt.isPresent()) { exercises.addAll(opt.get().getExercises()); } Link link = entityLinks.linkFor(Session.class) .slash(id) .slash(Constants.Rels.EXERCISES)

How to force Spring HATEOAS resources to render an empty embedded array?

风格不统一 提交于 2020-12-28 07:02:10
问题 I have the following controller method: @RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE, value = "session/{id}/exercises") public ResponseEntity<Resources<Exercise>> exercises(@PathVariable("id") Long id) { Optional<Session> opt = sessionRepository.findWithExercises(id); Set<Exercise> exercises = Sets.newLinkedHashSet(); if (opt.isPresent()) { exercises.addAll(opt.get().getExercises()); } Link link = entityLinks.linkFor(Session.class) .slash(id) .slash(Constants.Rels.EXERCISES)

How to make HATEOAS render empty embedded array

和自甴很熟 提交于 2020-12-15 06:24:37
问题 Usually CollectionModel will return an _embedded array, but in this example: @GetMapping("/{id}/productMaterials") public ResponseEntity<?> getProductMaterials(@PathVariable Integer id) { Optional<Material> optionalMaterial = materialRepository.findById(id); if (optionalMaterial.isPresent()) { List<ProductMaterial> productMaterials = optionalMaterial.get().getProductMaterials(); CollectionModel<ProductMaterialModel> productMaterialModels = new ProductMaterialModelAssembler

Migrating ResourceProcessor to HATEOAS 1.0.0 M1

你离开我真会死。 提交于 2020-03-23 07:22:07
问题 In my current Spring HATEOAS 0.25.1.RELEASE project I make heavy use of ResourceProcessor interfaces: @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; } }; } How can can I migrate my ResourceProcessors to Spring HATEOAS 1.0.0 M1? 回答1: In Spring HATEOAS 1.0 M1, a lot

Spring boot 2.2.0 Spring HateOas startup issue

六眼飞鱼酱① 提交于 2020-02-21 12:29:07
问题 I moved my project from spring boot 2.1.9 to 2.2.0. While starting the project am facing the below error messages. What could have caused, am not using hateoas in my pom.xml file either. Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.springframework.plugin.core.PluginRegistry<org.springframework.hateoas.client.LinkDiscoverer, org.springframework.http.MediaType>' available: expected single matching bean but found 17: