diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestController.java index 78266ad8f..b94a008d7 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryRestController.java @@ -899,7 +899,9 @@ public class RepositoryRestController Map entityDto = extractPropertiesLinkAware(linkedRepoMeta.rel(), linkedEntity, linkedRepoMeta.entityMetadata(), - baseUri); + buildUri(baseUri, + linkedRepoMeta.name(), + linkedId)); URI selfUri = addSelfLink(baseUri, entityDto, linkedRepoMeta.name(), linkedId); HttpHeaders headers = new HttpHeaders(); diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/test/webmvc/Family.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/test/webmvc/Family.java new file mode 100644 index 000000000..e5f3e7208 --- /dev/null +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/test/webmvc/Family.java @@ -0,0 +1,40 @@ +package org.springframework.data.rest.test.webmvc; + +import java.util.List; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.OneToMany; + +/** + * @author Jon Brisbin + */ +@Entity +public class Family { + + @Id @GeneratedValue private Long id; + private String surname; + @OneToMany + private List members; + + public Long getId() { + return id; + } + + public String getSurname() { + return surname; + } + + public void setSurname(String surname) { + this.surname = surname; + } + + public List getMembers() { + return members; + } + + public void setMembers(List members) { + this.members = members; + } + +} diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/test/webmvc/FamilyRepository.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/test/webmvc/FamilyRepository.java new file mode 100644 index 000000000..aa4a5a174 --- /dev/null +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/test/webmvc/FamilyRepository.java @@ -0,0 +1,9 @@ +package org.springframework.data.rest.test.webmvc; + +import org.springframework.data.repository.CrudRepository; + +/** + * @author Jon Brisbin + */ +public interface FamilyRepository extends CrudRepository { +} diff --git a/spring-data-rest-webmvc/src/test/resources/load_data.sh b/spring-data-rest-webmvc/src/test/resources/load_data.sh index 5324b2265..250e9386f 100755 --- a/spring-data-rest-webmvc/src/test/resources/load_data.sh +++ b/spring-data-rest-webmvc/src/test/resources/load_data.sh @@ -1,11 +1,14 @@ #!/bin/sh -curl -d '{"name" : "John Doe"}' -H "Content-Type: application/json" http://localhost:8080/person -curl -d '{"name" : "Jane Doe"}' -H "Content-Type: application/json" http://localhost:8080/person +curl -d '{"surname" : "Doe"}' -H "Content-Type: application/json" http://localhost:8080/family +curl -d '{"name" : "John Doe"}' -H "Content-Type: application/json" http://localhost:8080/people +curl -d '{"name" : "Jane Doe"}' -H "Content-Type: application/json" http://localhost:8080/people +curl -d 'http://localhost:8080/people/1 +http://localhost:8080/people/2' -H "Content-Type: text/uri-list" http://localhost:8080/family/1/members curl -d '{"postalCode":"12345","province":"MO","lines":["1 W 1st St."],"city":"Univille"}' -H "Content-Type: application/json" http://localhost:8080/address -curl -d "http://localhost:8080/address/1" -H "Content-Type: text/uri-list" http://localhost:8080/person/1/addresses +curl -d "http://localhost:8080/address/1" -H "Content-Type: text/uri-list" http://localhost:8080/people/1/addresses curl -d '{"postalCode":"54321","province":"MO","lines":["2 W 1st St."],"city":"Univille"}' -H "Content-Type: application/json" http://localhost:8080/address -curl -d "http://localhost:8080/address/2" -H "Content-Type: text/uri-list" http://localhost:8080/person/2/addresses +curl -d "http://localhost:8080/address/2" -H "Content-Type: text/uri-list" http://localhost:8080/people/2/addresses curl -d '{"type" : "twitter", "url": "#!/johndoe"}' -H "Content-Type: application/json" http://localhost:8080/profile -curl -d "http://localhost:8080/profile/1" -H "Content-Type: text/uri-list" http://localhost:8080/person/1/profiles +curl -d "http://localhost:8080/profile/1" -H "Content-Type: text/uri-list" http://localhost:8080/people/1/profiles curl -d '{"type" : "facebook", "url": "/janedoe"}' -H "Content-Type: application/json" http://localhost:8080/profile -curl -d '{"_links": [{"rel":"facebook", "href": "http://localhost:8080/profile/2"}]}' -H "Content-Type: application/json" http://localhost:8080/person/2/profiles +curl -d '{"_links": [{"rel":"facebook", "href": "http://localhost:8080/profile/2"}]}' -H "Content-Type: application/json" http://localhost:8080/people/2/profiles \ No newline at end of file