Updating example.

This commit is contained in:
Jon Brisbin
2013-04-03 00:10:26 +02:00
parent 2d3ebe50ec
commit d9b45a81d9
3 changed files with 14 additions and 20 deletions

View File

@@ -6,6 +6,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.data.rest.config.RepositoryRestConfiguration;
import org.springframework.data.rest.example.jpa.Person;
import org.springframework.data.rest.example.jpa.PersonRepository;
import org.springframework.data.rest.example.jpa.PersonValidator;
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration;
import org.springframework.hateoas.Link;
@@ -31,14 +32,9 @@ public class RestExporterExampleRestConfig extends RepositoryRestMvcConfiguratio
}
@Override protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
config.addResourceMappingForDomainType(Person.class)
config.setResourceMappingForDomainType(Person.class)
.addResourceMappingFor("lastName")
.setPath("surname");
config.addResourceMappingForDomainType(Person.class)
.addResourceMappingFor("siblings")
.setRel("siblings")
.setPath("siblings")
.setExported(false);
}
@Bean public ResourceProcessor<Resource<Person>> personResourceProcessor() {

View File

@@ -6,7 +6,6 @@ import javax.servlet.ServletRegistration;
import org.springframework.data.rest.example.jpa.JpaRepositoryConfig;
import org.springframework.data.rest.example.mongodb.MongoDbRepositoryConfig;
import org.springframework.data.rest.example.neo4j.Neo4jRepositoryConfig;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
@@ -20,10 +19,10 @@ public class RestExporterWebInitializer implements WebApplicationInitializer {
@Override public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext();
rootCtx.register(
//JpaRepositoryConfig.class,
//MongoDbRepositoryConfig.class,
JpaRepositoryConfig.class,
MongoDbRepositoryConfig.class
//GemfireRepositoryConfig.class,
Neo4jRepositoryConfig.class
//Neo4jRepositoryConfig.class
);
servletContext.addListener(new ContextLoaderListener(rootCtx));

View File

@@ -19,18 +19,17 @@ import org.springframework.data.rest.repository.annotation.RestResource;
@RestResource(rel = "people", path = "people")
public interface PersonRepository extends PagingAndSortingRepository<Person, Long> {
@RestResource(rel = "firstname", path = "firstname")
public Page<Person> findByFirstName(@Param("firstName") String firstName, Pageable pageable);
@RestResource(rel = "firstname", path = "firstname")
public Page<Person> findByFirstName(@Param("firstName") String firstName, Pageable pageable);
public Person findFirstPersonByFirstName(@Param("firstName") String firstName);
public Person findFirstPersonByFirstName(@Param("firstName") String firstName);
public Page<Person> findByCreatedGreaterThan(@Param("date") Date date, Pageable pageable);
public Page<Person> findByCreatedGreaterThan(@Param("date") Date date, Pageable pageable);
@Query("select p from Person p where p.created > :date")
public Page<Person> findByCreatedUsingISO8601Date(@Param("date")
@ConvertWith(
ISO8601DateConverter.class)
Date date,
Pageable pageable);
@Query("select p from Person p where p.created > :date")
public Page<Person> findByCreatedUsingISO8601Date(@Param("date")
@ConvertWith(ISO8601DateConverter.class)
Date date,
Pageable pageable);
}