spring-data-rest

Custom RepositoryRestController Mapping url throws 404 in spring-data-rest

拟墨画扇 提交于 2019-12-24 01:15:34
问题 I have written a custom RepositoryRestController using its corresponding entity repository. When performing request on this url, the query is running in my console, but the url returns 404. I also able to see the requestHandlerMapping for this url in logs. Refer my following code snippet. Repository: @RepositoryRestResource public interface FooRepository extends BaseRepository<Foo, Integer> { @RestResource(exported = false) List<Foo> findByName(String name); } Controller:

After successfully adding child entity with parent reference, child does not show under parent resource

心不动则不痛 提交于 2019-12-23 22:43:03
问题 I have two entities, Shelf and Book. A Shelf can have multiple Books (the relationship is bi-directional). I've exposed both of these as JpaRepositories. Here's the issue: I create a shelf by posting { "name":"sci-fi" } to /shelves.(success) I create a book for that shelf by posting { "name":"mybook", "shelf":"localhost:8080/shelves/1" } to /books. (success) When I get the book I just created at /books/1, it has the correct link to the parent shelf. But when I go to shelves/1/books, I get an

Spring Data Rest: “Unable to configure LocalContainerEntityManagerFactoryBean from @EntityScan”

扶醉桌前 提交于 2019-12-23 16:47:28
问题 I've got a REST service spring boot application, consisting into two separate maven projects: The first one myapp-data includes Spring Data JPA + Spring Data Rest Entities and Rest Repositories class definitions (I've isolated these in a separate maven project since I use them also in other applications besides my REST service). The secon myapp-services is a Spring Boot application that basically contains main method + configuration to expose the above Spring Data Rest repositories as REST

Spring Data REST MongoDB: Retrieve objects of DBRef instead of href

安稳与你 提交于 2019-12-23 16:00:13
问题 Hello experts @ stackOverflow, We are using Spring Data REST MongoDB. Is it possible to eager load the child Objects, instead of Hyperlinks - which are annotated using @DBRef? Please refer the Process.templates attribute below. Here is our Model: import org.springframework.data.annotation.Id; import org.springframework.data.mongodb.core.mapping.DBRef; import org.springframework.data.mongodb.core.mapping.Document; import java.util.ArrayList; import java.util.List; @Document(collection =

Spring-data-rest switch between hal+json and plain json

折月煮酒 提交于 2019-12-23 14:19:15
问题 I've been using the defaultMediaType config property set to "application/json" to get "normal" JSON, which is easier to handle and all I need: { "links": [ ], "content": [ { "username": "admin", "id": 1, "authorities": [ "ROLE_ADMIN" ], "content": [ ], "links": [ { "rel": "self", "href": "http://localhost:8080/apiv1/data/users/1" }, { "rel": "logisUser", "href": "http://localhost:8080/apiv1/data/users/1" }, { "rel": "mandant", "href": "http://localhost:8080/apiv1/data/users/1/mandant" } ] },.

How to secure association resources?

蓝咒 提交于 2019-12-23 10:28:13
问题 The problem can be defined by the following example: I have a class MainClass which is related with another class called AssociatedClass by a @OneToOne relation. Both have an exposed Repository so I can do a GET on the URL /mainClasses/{some_id} and on the URL /associatedClasses/{some_id} . However, the AssociatedClassRepository has the following code: @RepositoryRestResource public interface AssociatedClassRepository extends PagingAndSortingRepository<AssociatedClass, String> { @Override

Dealing with m-to-n relations in @RepositoryRestResource

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-23 10:01:45
问题 Preface I want to create a sub-resource of another resource in one call. These resources have a @ManyToMany relationship: Users and Groups. I do not want to create first a user, then the group and after that the relation as it is shown in Working with Relationships in Spring Data REST - simply because I think a resource that cannot exist on its own, such as a group, should only be created if at least one user is also associated with that resource. For this I require a single endpoint like

How to expose custom DTO crud repository with Spring data REST?

泄露秘密 提交于 2019-12-23 08:50:11
问题 I don't want to expose my model classes (jpa entities), rather different subset of their attributes with different data transport objects (DTOs). The idea is DTO CrudRepository <-> JpaRepository <-> entities , and I want to expose via Spring Data REST the DTO CrudRepository . Example: Entity: @Entity @Table(name = "groups") public class Group { private Long id; private String name; private Set<User> users; // other attributes @Id @GeneratedValue @Column(name = "group_id") public Long getId()

Select one column using Spring Data JPA

烈酒焚心 提交于 2019-12-23 07:03:02
问题 Does anyone have any idea how to get a single column using Spring Data JPA? I created a repository like below in my Spring Boot project, but always get the {"cause":null,"message":"PersistentEntity must not be null!"} error when accessing the Restful URL. @RepositoryRestResource(collectionResourceRel = "users", path = "users") public interface UsersRepository extends CrudRepository<Users, Integer> { @Query("SELECT u.userName FROM Users u") public List<String> getUserName(); } Then if I access

SpringDataRest and show welcome-file-list/disable link discovery

会有一股神秘感。 提交于 2019-12-23 05:27:55
问题 I am using spring-data-rest(1.0.0.RELEASE) in my spring-mvc application But I am getting following problem In my WebConfig @Import(RepositoryRestMvcConfiguration.class) public static class WebConfiguration extends WebMvcConfigurationSupport{...} Here this case RepositoryRestMvcConfiguration has a bean RepositoryRestController which has method listRepositories(...) annotated with @RequestMapping(value = "/", method = RequestMethod.GET) Now the problem is that when I am hitting at the root