Code Monkey home page Code Monkey logo

spring-data-rest's Introduction

Spring Data REST icon?job=spring data rest%2Fmain&subject=Build Gitter Revved up by Gradle Enterprise

The goal of the project is to provide a flexible and configurable mechanism for writing simple services that can be exposed over HTTP.

This takes your Spring Data repositories and front-ends them with HTTP, allowing you full CRUD capability over your entities, to include managing associations.

Features

Code of Conduct

This project is governed by the Spring Code of Conduct. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to [email protected].

Getting Started

Here is a quick teaser of an application using Spring Data REST in Java:

@CrossOrigin
@RepositoryRestResource(path = "people")
public interface PersonRepository extends CrudRepository<Person, Long> {

  List<Person> findByLastname(String lastname);

  @RestResource(path = "byFirstname")
  List<Person> findByFirstnameLike(String firstname);
}

@Configuration
@EnableMongoRepositories
class ApplicationConfig extends AbstractMongoConfiguration {

  @Override
  public MongoClient mongoClient() {
    return new MongoClient();
  }

  @Override
  protected String getDatabaseName() {
    return "springdata";
  }
}
curl -v "http://localhost:8080/people/search/byFirstname?firstname=Oliver*&sort=name,desc"

Maven configuration

Add the Maven dependency:

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-rest</artifactId>
  <version>${version}.RELEASE</version>
</dependency>

If you’d rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-rest</artifactId>
  <version>${version}-SNAPSHOT</version>
</dependency>

<repository>
  <id>spring-snapshot</id>
  <name>Spring Snapshot Repository</name>
  <url>https://repo.spring.io/snapshot</url>
</repository>

Getting Help

Having trouble with Spring Data? We’d love to help!

Reporting Issues

Spring Data uses GitHub as issue tracking system to record bugs and feature requests. If you want to raise an issue, please follow the recommendations below:

  • Before you log a bug, please search the issue tracker to see if someone has already reported the problem.

  • If the issue doesn’t already exist, create a new issue.

  • Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using and JVM version.

  • If you need to paste code, or include a stack trace use GitHub’s flavor of Markdown and wrap your code with triple-backquotes.

  • If possible try to create a test-case or project that replicates the issue. Attach a link to your code or a compressed file containing your code.

Building from Source

You don’t need to build from source to use Spring Data (binaries in repo.spring.io), but if you want to try out the latest and greatest, Spring Data can be easily built with the maven wrapper. You also need JDK 17.

 $ ./mvnw clean install

If you want to build with the regular mvn command, you will need Maven v3.5.0 or above.

Also see CONTRIBUTING.adoc if you wish to submit pull requests, and in particular please sign the Contributor’s Agreement before your first non-trivial change.

Building reference documentation

Building the documentation builds also the project without running tests.

 $ ./mvnw clean install -Pantora

The generated documentation is available from target/site/reference/html/index.html.

Guides

The spring.io site contains several guides that show how to use Spring Data step-by-step:

Examples

License

Spring Data REST is Open Source software released under the Apache 2.0 license.

spring-data-rest's People

Contributors

alexleigh avatar avandecreme avatar benwarfield-usds avatar brentwillems avatar candrews avatar cedricziel avatar ceefour avatar christophstrobl avatar dannyarcher avatar darioseidl avatar davidlj95 avatar elnur avatar ericbottard avatar erichaagdev avatar f-cramer avatar fbiville avatar florianluediger avatar goodloot avatar gregturn avatar jbrisbin avatar jxblum avatar mp911de avatar odrotbohm avatar schauder avatar spring-builds avatar sxhinzvc avatar toedter avatar trampi avatar wilkinsona avatar yejianfengblue avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spring-data-rest's Issues

1.0.0.RC1 - View Resolvers

Hi,
in order to try the new capability of customizing rest's views since 1.0.0.RC1, i've a problem with this hint (from doc "Adding Spring Data REST to an existing Spring MVC Application"):

To register your own custom view for any of these internal view names, you need to subclass RepositoryRestMvcConfiguration.contentNegotiatingViewResolver()

because this method is private so we cannot subclass it.
More in general i can be very concerned about an example of customizing rest's views, because actually in rest seems it isn't possible to obtain, for example, a list of entities including theirs attributes.
Tks

Query methods expecting complex parameter types not handled correctly [DATAREST-27]

Oliver Drotbohm opened DATAREST-27 and commented

Assume you have a repository like this:

interface OrderRepository extends CrudRepository<Order, Long> {

  List<Order> findByCustomer(Customer customer);
}

If the method now gets exposed, how shall one provide the Customer object for the GET request? Currently a plain call to

http://localhost:8080/order/search/findByCustomer

causes a

java.lang.NullPointerException
	at java.io.StringReader.<init>(StringReader.java:33)
	at org.codehaus.jackson.JsonFactory.createJsonParser(JsonFactory.java:636)
	at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1863)
	at org.springframework.data.rest.webmvc.RepositoryRestController.query(RepositoryRestController.java:418)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:643)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:450)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1067)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:377)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1001)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
	at org.eclipse.jetty.server.Server.handle(Server.java:360)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:622)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
	at java.lang.Thread.run(Thread.java:680)

Affects: 1.0.0.RC1

Create XML namespace that controls which repositories are exported [DATAREST-1]

Mark Pollack opened DATAREST-1 and commented

The user should be able to select a subset of the Spring Data Repositories that are exported. Also, the user should be able to export subset of the full CRUD Repository functionality. An example would be to export only read operations. There could perhaps be a tie-in as well with security, a person who is authenticated with an admin role would have access to full CRUD, where as other roles would be more readonly. Might need a seperate JIRA issue to discuss how security could be either demoed in the sample or more dedicated support for ease of use/configuration provided


No further details from DATAREST-1

Create an extension mechanism that lets users tie into process of turning a domain object into a representation object [DATAREST-7]

Jon Brisbin opened DATAREST-7 and commented

We need to be able to inspect, validate, or alter the representation of the object going back to the client. One way to do this is to provide a system of annotations that users can put on their classes that the exporter will recognize and call when that lifecycle event is triggered. The exporter could invoke a handler method of a class annotated with a @ResourceHandler annotation and specifying the domain class it's a handler for


Affects: 1.0 - M1

2 votes, 2 watchers

Error creating bean with name 'jpaRepositoryMetadata

Hi,
after using the sample provided in the github repository I tried to build my own sample, based on Spring Data-JPA. Currently I always get an exception during container initialization:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaRepositoryMetadata' defined in class org.springframework.data.rest.webmvc.RepositoryRestConfiguration: Invocation of init method failed; nested exception is java.lang.NullPointerException

Any idea, what I am doing wrong?

entityMetadata().versionAttribute throws NullPointerException (Line 450)

Hi,
after getting the converter running it ran into the next thing. Perhaps a bug.

Object version = repoMeta.entityMetadata().versionAttribute().get(entity);
          if (null != version) {

This results in a NullPointerException if the @Version is not set in the specific Entity. I fixed it via if clause checking wether repoMeta.entityMetadata().versionAttribute() is null.

java.lang.IllegalArgumentException: Resource must not be null

Hi,
using the latest build I get the following error.

16:54:59.694 [tomcat-http--11] DEBUG o.s.d.r.w.RepositoryRestExporterServlet - DispatcherServlet with name 'exporter' processing GET request for [/rest/]
16:54:59.694 [tomcat-http--11] DEBUG o.s.d.r.w.RepositoryExporterHandlerMapping - Looking up handler method for path /
16:54:59.694 [tomcat-http--11] DEBUG o.s.d.r.w.RepositoryExporterHandlerMapping - Returning handler method [public org.springframework.web.servlet.ModelAndView org.springframework.data.rest.webmvc.RepositoryRestController.listRepositories(org.springframework.web.util.UriComponentsBuilder)]
16:54:59.694 [tomcat-http--11] DEBUG o.s.d.r.w.RepositoryRestExporterServlet - Last-Modified value for [/rest/] is: -1
16:54:59.694 [tomcat-http--11] DEBUG o.s.d.r.w.RepositoryRestExporterServlet - Could not complete request
java.lang.IllegalArgumentException: Resource must not be null
    at org.springframework.util.Assert.notNull(Assert.java:112) ~[spring-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.transaction.support.TransactionSynchronizationUtils.unwrapResourceIfNecessary(TransactionSynchronizationUtils.java:62) ~[spring-tx-3.2.0.BUILD-SNAPSHOT.jar:3.2.0.BUILD-SNAPSHOT]
    at org.springframework.transaction.support.TransactionSynchronizationManager.hasResource(TransactionSynchronizationManager.java:124) ~[spring-tx-3.2.0.BUILD-SNAPSHOT.jar:3.2.0.BUILD-SNAPSHOT]
    at org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor.preHandle(OpenEntityManagerInViewInterceptor.java:71) ~[spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapter.preHandle(WebRequestHandlerInterceptorAdapter.java:54) ~[spring-webmvc-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:891) ~[spring-webmvc-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827) ~[spring-webmvc-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) [spring-webmvc-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778) [spring-webmvc-3.1.0.RELEASE.jar:3.1.0.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) [na:na]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) [na:na]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) [na:na]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) [na:na]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225) [na:na]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) [na:na]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) [na:na]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) [na:na]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) [na:na]
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) [na:na]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) [na:na]
    at com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(HttpRequestOperationCollectionValve.java:88) [na:na]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) [na:na]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999) [na:na]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) [na:na]
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307) [na:na]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0_01]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0_01]
    at java.lang.Thread.run(Thread.java:722) [na:1.7.0_01]

Any idea?

Improve self-descriptiveness of the search links [DATAREST-31]

Oliver Drotbohm opened DATAREST-31 and commented

Currently the exposed search links do not provide means to discover which parameters of which types have to be provided when executing the search. I propose we extend the link elements to something as follows:

{ rel : "…",
  href : "…",
  params : [
    { name : "username", type : [ "String" ] },
    { name : "customer", type : [ "long", "uri" ] },
    { name : "emailAddress", type [ "String" ] }
  ] }

The types should be resolved as follows:

  1. if the method parameter type is a primitive one, use the type directly
  2. if the type is a repository managed one, expose the id type as well as uri as the backend id can be derived from the uri and clients shouldn't actually use ids other than a URI anyway.
  3. if the type is neither 1. or 2. expect it to be convertible from a String by the ConversionService (can actually be checked by calling ….canConvert(String.class, targetType)).

Complex types can theoretically also be provided using the JSON representation of the type but that would require rendering JSONSchema and submitting more data than actually necessary by the client


Issue Links:

  • DATAREST-164 Add description attribute to links

  • DATAREST-229 RepositoryEntityLinks should exposed templated link for pageable collection resources

Referenced from: commits 61d3d1c, 5409bfd, 4b6f0f6

1 votes, 2 watchers

LazyInitializationException()

Hi,
it seems to be a problem with JoinTables and Lazy-Loading. Each Entity having a JoinTable results in a:

Request processing failed; nested exception is org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: de.model.Entity.Relations, no session or session was closed

The JoinTable configuration for that looks like that:

 @ManyToMany(fetch = FetchType.LAZY, cascade=CascadeType.MERGE)
    @JoinTable(name="\"Entity_Relation\"",
            joinColumns=@JoinColumn(name="\"Entity_id\""),
            inverseJoinColumns=@JoinColumn(name="\"Relation_id\""))
    private Set<Relation> relation;

Is that a implementation error on my side, or something missing?

Logging

Hi Jon,
me again. Today I was testing SD REST with some JavaScript Client side stuff. Something happend to me, which was quite annoying and could be improved I think. Taking a look at the following snippet:

 @SuppressWarnings({"unchecked"})
  private <V> V readIncoming(HttpInputMessage request, MediaType incomingMediaType, Class<V> targetType) throws IOException {
    for (HttpMessageConverter converter : httpMessageConverters) {
      if (converter.canRead(targetType, incomingMediaType)) {
        return (V) converter.read(targetType, request);
      }
    }
    return null;
  }

It would help a lot, if some logging would give me the output if converter.read(...); failed and which property was related to it. In some case creating a client-side JSON objects lead to typo errors, which would be much easier to debug if I could see on debugging server side output, which field was related. As far as I know, JacksonMapper throws this exception, so it would be just necessary to log and chain it through...

What do you think?

No converter found capable of converting from type java.lang.String to type java.util.UUID

Hi,
during my first usage I found a small but essential part missing. A conversion from String to UUID. I think this issue will arise in many projects where the primary identifier is a UUID.

The stack trace looks like this:

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.lang.String to type java.util.UUID
org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:475)
org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:175)
org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:154)
org.springframework.data.rest.webmvc.RepositoryRestController.stringToSerializable(RepositoryRestController.java:1000)
org.springframework.data.rest.webmvc.RepositoryRestController.entity(RepositoryRestController.java:440)

Do I need to extend the ConversionService, or will a UUID Converter be part of the implementation in future?

Security, Validation and documentation

Hi Jonathan,
I am currently reading the documentation as soon as you released it, because as you might see I am quite interested in this project. One thing I was wondering about from the beginning on is, how do you plan to integrate validation and security? For validation I saw during container startup, that you are scanning for a validation.xml file, is that right?

One short side-note. From my point of view it would be beneficial, if the wiki would provide the information for the Maven - Repository as well. Most of all (if exists) a reference to nightly builds, for testing and using the latest releases.

Best regards

Irritating behavior in rest/search/searchMethod

Hi,
using the latest builds a method I created does not work anymore. The reason is the following when I do

http://192.168.125.196:8080/rest/car/search/findCarForDriver?id=c27a15c9-a06f-4222-837a-9e64ef79e24b

I get the following response:

[
{
"rel": "car.Car.c27a15c9-a06f-4222-837a-9e64ef79e24b",
"href": "http://192.168.125.196:8080/rest/car/c27a15c9-a06f-4222-837a-9e64ef79e24b"
}
]

The documentation says: "To query for entities using this search method, add a query parameter to the URL. The response will be a list of links to the top-level URL for that resource."

But essentially the list of links normally looks like that:

{
"_links": [
{
"rel": "car.getCarByDriverId",
"href": "http://192.168.125.196:8080/rest/car/search/getCarByDriverId"
},
{
"rel": "car.findCarForDriver",
"href": "http://192.168.125.196:8080/rest/car/search/findCarForDriver"
}
]
}

The problem with the first result set is, that I am not able to automatically parse it into LinkType, because Jackson throws an exception:

de.model.api.exception.RestHelperException: RestHelper.list(): Could not read JSON: Can not deserialize instance of de.model.model.schema.BaseType out of START_ARRAY token
 at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@634be93a; line: 1, column: 1]; nested exception is org.codehaus.jackson.map.JsonMappingException: Can not deserialize instance of de.model.model.schema.BaseType out of START_ARRAY token
 at [Source: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@634be93a; line: 1, column: 1]
    at de.model.api.schema.RestServiceImpl.list(RestServiceImpl.java:142)
    at de.model.api.schema.RestServiceImpl.searchOne(RestServiceImpl.java:305)
    at de.model.api.rest.ProviderTest.testGetProvider(ProviderTest.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)

I am sure, that it worked before. So is there any reason, that this changed?

EDIT: Ok, taking a look into the code I found the reason for it in RepositoryRestController.java lines 370 and following. Only if the returned entity is of type Collection, it is rendered as LinkList. From my point of view, it should always return a Link. Any option to discuss that?

Servlet API dependency should be provided scope [DATAREST-24]

Oliver Drotbohm opened DATAREST-24 and commented

The servlet API dependency should be in scope provided as it will usually be provided by the container starting the application and an additional Servlet API JAR might cause class loading issues.

Beyond that client projects have to exclude the dependency explicitly if they want to use it with the Servlet API 3.0 for example


Affects: 1.0.0.RC1

Parameters for executing query methods not checked properly [DATAREST-26]

Oliver Drotbohm opened DATAREST-26 and commented

Calling a finder method without the parameters needed seems to result in handling null values into the query method execution:

org.springframework.dao.DataRetrievalFailureException: nested exception is java.lang.reflect.InvocationTargetException
	at org.springframework.data.rest.webmvc.RepositoryRestController.query(RepositoryRestController.java:488)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:643)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:450)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1067)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:377)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1001)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
	at org.eclipse.jetty.server.Server.handle(Server.java:360)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:622)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
	at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.data.rest.webmvc.RepositoryRestController.query(RepositoryRestController.java:426)
	... 41 more
Caused by: org.springframework.dao.InvalidDataAccessApiUsageException: [Assertion failed] - this argument is required; it must not be null; nested exception is java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
	at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:301)
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:106)
	at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
	at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:91)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
	at $Proxy57.findByDescriptionContaining(Unknown Source)
	... 46 more
Caused by: java.lang.IllegalArgumentException: [Assertion failed] - this argument is required; it must not be null
	at org.springframework.util.Assert.notNull(Assert.java:112)
	at org.springframework.util.Assert.notNull(Assert.java:123)
	at org.springframework.data.jpa.repository.query.ParameterMetadataProvider$ParameterMetadata.prepare(ParameterMetadataProvider.java:156)
	at org.springframework.data.jpa.repository.query.CriteriaQueryParameterBinder.bind(CriteriaQueryParameterBinder.java:68)
	at org.springframework.data.jpa.repository.query.ParameterBinder.bind(ParameterBinder.java:108)
	at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$CountQueryPreparer.invokeBinding(PartTreeJpaQuery.java:196)
	at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$QueryPreparer.createQuery(PartTreeJpaQuery.java:121)
	at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.doCreateCountQuery(PartTreeJpaQuery.java:82)
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.createCountQuery(AbstractJpaQuery.java:148)
	at org.springframework.data.jpa.repository.query.JpaQueryExecution$PagedExecution.doExecute(JpaQueryExecution.java:99)
	at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:55)
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:95)
	at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:85)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:313)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
	... 53 more

The exception in ParameterMetadataProvider is thrown if someone hands null into the method massaging the String parameter for Contains keywords where piping in null obviously doesn't make much sense.

The controller should reject GET requests without the necessary parameters provided


Affects: 1.0.0.RC1

paging with parameters [DATAREST-21]

wims.tijd opened DATAREST-21 and commented

missing parameter findBy in href .prev and .next

Page<LoanInfo> findByNsn(@Param("nsn") String nsn, Pageable pageable);

http://localhost:9090/hateos/loaninfo/search/findByNsn?nsn=2355-DE-004-0342&page=2&limit=5

{
    "rel": "loaninfo.prev",
    "href": "http://localhost:9090/hateos/loaninfo/search/findByNsn?page=1&limit=5"
},
{
    "rel": "loaninfo.next",
    "href": "http://localhost:9090/hateos/loaninfo/search/findByNsn?page=3&limit=5"
}

]


Affects: 1.0.0.RC1

Referenced from: commits f969f92

NullPointerException in DelegatingConversionService [DATAREST-25]

Oliver Drotbohm opened DATAREST-25 and commented

Steps to reproduce.

  1. Have an entity with a repository interface exposing a finder.
  2. Start the application with no data
  3. Navigate to the finder method (e.g. http://localhost:8080/customer/search/findByEmailAddress)
  4. Get NullPointerException with the following stack trace
2012-07-26 12:40:40.141:WARN:oejs.ServletHandler:/customer/search/findByEmailAddress
java.lang.NullPointerException
	at org.springframework.data.rest.core.convert.DelegatingConversionService.convert(DelegatingConversionService.java:55)
	at org.springframework.data.rest.webmvc.RepositoryRestController.query(RepositoryRestController.java:414)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:643)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:450)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1067)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:377)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:192)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1001)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
	at org.eclipse.jetty.server.Server.handle(Server.java:360)
	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:454)
	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:890)
	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:944)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:622)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
	at java.lang.Thread.run(Thread.java:680)

Affects: 1.0.0.RC1

Error code handling

Hi,

Using beforeDelete validation, while doing delete operation I'm getting error "500 validation failed" instead I need to get "405 Method Not allowed" .
I'm trying to block the crud operations, is there any way to do? what is the best way to handle this? can you help me.

Searches which returns null gives NPE [DATAREST-23]

Aleksander Blomskøld opened DATAREST-23 and commented

A search which returns null gives NullPointerException in RepositoryRestController.

Example stack trace:

java.lang.NullPointerException
at org.springframework.data.rest.webmvc.RepositoryRestController.query(RepositoryRestController.java:442)
at org.springframework.data.rest.webmvc.RepositoryRestController$$FastClassByCGLIB$$5ba1a185.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at
xxx(xxx.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at
xxx(xxx.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622)
at org.springframework.data.rest.webmvc.RepositoryRestController$$EnhancerByCGLIB$$eb30ada5.query(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)

A simple fix would be to add a if(null != result) before doing l.add(result) around line 429 in RepositoryRestController


Affects: 1.0.0.RC1

Referenced from: commits 6867d07

1 votes, 2 watchers

The collection resource should not contain a link to searches if no query methods are exported [DATAREST-30]

Oliver Drotbohm opened DATAREST-30 and commented

Currently the response to a call of the collection resource (e.g. /product) contains a link to a search resource product.source that - if followed - returns an empty list only. While this is valid to some degree the essence of hypermedia is that the presence or not-presence of links indicate which actions are reasonable for a client.

I suggest to not render the search link if there are no searches exported


No further details from DATAREST-30

Create an extension mechanism

We need to create an extension mechanism so that people can easily tie into the various lifecycle events within the REST exporter itself.

RepositoryExporterSupport missing isSetLike(); ?

Hi,
me again. Trying to open a referenced set I got the following exception: org.springframework.data.rest.repository.RepositoryNotFoundException: No repository found for type java.util.Set

Taking a look into RepositoryExporterSupport, shows me that

if (attrMeta.isCollectionLike() || attrMeta.isMapLike()) {
      return repositoryMetadataFor(attrMeta.elementType());
    }

Does not have a attrMeta.isSetLike(); although it is defined in AttributeMetadata. Is this not implemented yet?

Self Link wrong when opening a related entity?

Hi,
I am not sure if this is a bug, or me having a misunderstanding. When I open up an entity and the according relation then the ouput looks like this:

{
"startDate": 1337687944636,
"sequence": 0,
"_links": [
{
"rel": "entities.Entity.relation",
"href": "http://localhost:8080/rest/relation"
},
{
"rel": "self",
"href": "http://localhost:8080/rest/relation/3839196d-6c95-494b-a405-e6d9f120b252"
}
],
"endDate": 1337687944636,
"type": 0
}

Self links to the parent entity but not the opened entity itself. The according link to that looks like this:
http://localhost:8080/rest/relation/3839196d-6c95-494b-a405-e6d9f120b252/entity/45c7ad65-09e6-45e4-a549-eda11f4f70b4

What I am doing wrong?

Question about _links.rel

Hi,
I have another question. When I browse my entities the following occurs. On the index page each object is listed like:

  • objectOne
  • objectTwo
  • objectThree

As they represent collections of the particular object, it should append an s automatically, or? Because, if I click on objectOne by selecting on of the objects the model path looks like that:

objectOne.ObjectOne

Perhaps it would be better, if it would be:

objectOnes.ObjectOne

I know I am bit sticky, but what do you think about that?

Second question regarding links

Hi Jon,
I tried to go on today. I found another thing I am thinking about right now:

Recapturing the example from yesterday with the Car/Tires. Being at:

http://localhost:8080/rest/Car/f32d24f2-aa4b-456f-9121-6e620ade389f/Tires/9a745dbc-708d-4faa-9681-b57032762f0c

and having the following output:

{
"pressure": 10,
"_links": [
{
"rel": "tires.Tire.bolts",
"href": "http://localhost:8080/rest/bolts",
"rel": "tires.Tire.car",
"href": "http://localhost:8080/rest/car"
},
{
"rel": "self",
"href": "http://localhost:8080/rest/Tire/9a745dbc-708d-4faa-9681-b57032762f0c"
}
],
"type": 0
}

Taking bolts as an example, following the link would get me to all bolts in database. When I click the (Self) link http://localhost:8080/rest/Tire/9a745dbc-708d-4faa-9681-b57032762f0c the output looks like this:

{
"pressure": 10,
"_links": [
{
"rel": "tires.Tire.bolts",
"href": "http://localhost:8080/rest/Tire/9a745dbc-708d-4faa-9681-b57032762f0c/bolts",
"rel": "tires.Tire.car",
"href": "http://localhost:8080/rest/Tire/9a745dbc-708d-4faa-9681-b57032762f0c/car"
},
{
"rel": "self",
"href": "http://localhost:8080/rest/Tire/9a745dbc-708d-4faa-9681-b57032762f0c"
}
],
"type": 0
}

Which is slightly different and also what I would have expected in snippet one. Is this intended behavior?

Johannes

@MappedSuperclass [DATAREST-28]

wims.tijd opened DATAREST-28 and commented

entity extending Abstract base class :
org.springframework.data.jpa.domain.AbstractPersistable

resolved by :

org.springframework.data.rest.webmvc.RepositoryRestController.entity
org.springframework.data.rest.webmvc.RepositoryRestController.linkedEntity

results in :

Provided id of the wrong type for class repository.domain.ColumnMetaData. Expected: class java.lang.Long, got class java.lang.String; nested exception is java.lang.IllegalArgumentException: Provided id of the wrong type for class repository.domain.ColumnMetaData. Expected: class java.lang.Long, got class java.lang.String


Affects: 1.0.0.RC1

Issue Links:

  • DATAREST-433 Inheritance of Id property from abstract base class causes NullPointerException

Primary identifier missing

Hi Jon,
this is more a question than an issue report. What I was wondering about from the beginning on is, why the primary identifier in my case each Id of the entity is empty? In many client applications the primary identifier is important for application logic.

I did some short research, but I wasn't able to find some valuable information wether it make sense or not to include the primary id.

Could you explain it to me?

Support For JSONP callback [DATAREST-22]

James Arnott opened DATAREST-22 and commented

JSONP is supported in lots of frameworks and mandatory to some, to allow cross domain calls to JSON data.

A parameter is added to the URL to specify the callback: &jsoncallback=callback1234.

The entire json is then wrapped in callback1234({"mydata": "test"})

The parameter (jsoncallback) can be arbitrary so it should be configurable


Affects: 1.0.0.RC1

Referenced from: commits f969f92

Query methods should ne be exposed if they don't use the @Param annotation for parameters [DATAREST-29]

Oliver Drotbohm opened DATAREST-29 and commented

As the parameter names of the query methods cannot be derived from the interface (due to a limitation of the JVM) they effectively need to be annotated using @Param to be able to be invoked by a client. Currently the methods still get exposed but cannot be invoked properly as parameter binding will always fail.

I suggest to not expose the methods not annotated with @Param and trigger a WARN log unless they are explicitly excluded from being exported through @RestResource(exported = false)


Affects: 1.0.0.RC2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.