java.lang.IllegalArgumentException

tip

If you're unit testing, you should instantiate only the service and mock the dependencies. If you're testing integration, you should add all the mocking to the configurations file.

You have a different solution? A short tip here would help you and many other users who saw this issue last week.

  • Currently we don't support {{GeoPage}} as a result type for finder- methods with Spring Data Rest Repositories. I stumbled upon this while writing a simple Web Front-end for the starbucks spring-data-examples app. If I change the return type of {{StoreRepository.findByAddressLocationNear}} from {{Page<Store>}} to {{GeoPage<Store>}} and issue a query via curl, I get the following error message: {code} {"cause":null,"message":"PersistentEntity must not be null!"} {code} {code:java} Page<Store> findByAddressLocationNear(// @Param("location") Point location, @Param("distance") Distance distance, Pageable pageable); {code} Steps to reproduce: 1) Run the starbucks example app 2) Perfom a get request to get stores near timesquare via curl {code} curl http://localhost:8080/stores/search/findByAddressLocationNear\?location\=40.740337%2C-73.995146\&distance\=0.5miles\&page\=0\&size\=100 {code} On the server one should see the following stacktrace: {code} java.lang.IllegalArgumentException: PersistentEntity must not be null! at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.<init>(PersistentEntityResource.java:155) at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.<init>(PersistentEntityResource.java:137) at org.springframework.data.rest.webmvc.PersistentEntityResource.build(PersistentEntityResource.java:129) at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.wrap(PersistentEntityResourceAssembler.java:105) at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:84) at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:45) at org.springframework.data.web.PagedResourcesAssembler.createResource(PagedResourcesAssembler.java:137) at org.springframework.data.web.PagedResourcesAssembler.toResource(PagedResourcesAssembler.java:96) at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.entitiesToResources(AbstractRepositoryRestController.java:228) at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.resultToResources(AbstractRepositoryRestController.java:215) at org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:291) at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:744) {code} The problem is that a {{GeoPage}} wraps the actual result within a {{GeoResult}} which crashes in {{org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler#wrap}} since {{source.getClass()}} is now a {{GeoResult}} instead of the actual entity type ({{Store}} in this case). A quick hack for testing was to change the {{wrap(...)}} method to handle the special case of a {{GeoResult}}, which leads to the expected result. {code} private Builder wrap(Object instance, Object source) { Object element = source; if(element instanceof GeoResult){ element = ((GeoResult)source).getContent(); } PersistentEntity<?, ?> entity = repositories.getPersistentEntity(element.getClass()); return PersistentEntityResource.build(instance, entity).// withEmbedded(getEmbeddedResources(element)).// withLink(getSelfLinkFor(element)); } {code} Yields: {code:json} { "_links" : { "self" : { "href" : "http://localhost:8080/stores/search/findByAddressLocationNear?location=40.740337%2C-73.995146&distance=0.5miles&page=0&size=100{&sort}", "templated" : true } }, "_embedded" : { "geoResults" : [ { "content" : { "name" : "22nd St. & Sixth Ave.", "address" : { "street" : "684 Avenue of the Americas", "city" : "New York", "zip" : "10010-5110", "location" : { "x" : -73.993237, "y" : 40.741844 } } }, "distance" : { "value" : 0.14448373542533344, "metric" : "MILES" }, "_links" : { "self" : { "href" : "http://localhost:8080/stores/54b63d2dd4c669674288254a" } } }, ... } ] }, "page" : { "size" : 100, "totalElements" : 19, "totalPages" : 1, "number" : 0 } } {code}
    via by Thomas Darimont,
  • Currently we don't support {{GeoPage}} as a result type for finder- methods with Spring Data Rest Repositories. I stumbled upon this while writing a simple Web Front-end for the starbucks spring-data-examples app. If I change the return type of {{StoreRepository.findByAddressLocationNear}} from {{Page<Store>}} to {{GeoPage<Store>}} and issue a query via curl, I get the following error message: {code} {"cause":null,"message":"PersistentEntity must not be null!"} {code} {code:java} Page<Store> findByAddressLocationNear(// @Param("location") Point location, @Param("distance") Distance distance, Pageable pageable); {code} Steps to reproduce: 1) Run the starbucks example app 2) Perfom a get request to get stores near timesquare via curl {code} curl http://localhost:8080/stores/search/findByAddressLocationNear\?location\=40.740337%2C-73.995146\&distance\=0.5miles\&page\=0\&size\=100 {code} On the server one should see the following stacktrace: {code} java.lang.IllegalArgumentException: PersistentEntity must not be null! at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.<init>(PersistentEntityResource.java:155) at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.<init>(PersistentEntityResource.java:137) at org.springframework.data.rest.webmvc.PersistentEntityResource.build(PersistentEntityResource.java:129) at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.wrap(PersistentEntityResourceAssembler.java:105) at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:84) at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:45) at org.springframework.data.web.PagedResourcesAssembler.createResource(PagedResourcesAssembler.java:137) at org.springframework.data.web.PagedResourcesAssembler.toResource(PagedResourcesAssembler.java:96) at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.entitiesToResources(AbstractRepositoryRestController.java:228) at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.resultToResources(AbstractRepositoryRestController.java:215) at org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:291) at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:744) {code} The problem is that a {{GeoPage}} wraps the actual result within a {{GeoResult}} which crashes in {{org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler#wrap}} since {{source.getClass()}} is now a {{GeoResult}} instead of the actual entity type ({{Store}} in this case). A quick hack for testing was to change the {{wrap(...)}} method to handle the special case of a {{GeoResult}}, which leads to the expected result. {code} private Builder wrap(Object instance, Object source) { Object element = source; if(element instanceof GeoResult){ element = ((GeoResult)source).getContent(); } PersistentEntity<?, ?> entity = repositories.getPersistentEntity(element.getClass()); return PersistentEntityResource.build(instance, entity).// withEmbedded(getEmbeddedResources(element)).// withLink(getSelfLinkFor(element)); } {code} Yields: {code:json} { "_links" : { "self" : { "href" : "http://localhost:8080/stores/search/findByAddressLocationNear?location=40.740337%2C-73.995146&distance=0.5miles&page=0&size=100{&sort}", "templated" : true } }, "_embedded" : { "geoResults" : [ { "content" : { "name" : "22nd St. & Sixth Ave.", "address" : { "street" : "684 Avenue of the Americas", "city" : "New York", "zip" : "10010-5110", "location" : { "x" : -73.993237, "y" : 40.741844 } } }, "distance" : { "value" : 0.14448373542533344, "metric" : "MILES" }, "_links" : { "self" : { "href" : "http://localhost:8080/stores/54b63d2dd4c669674288254a" } } }, ... } ] }, "page" : { "size" : 100, "totalElements" : 19, "totalPages" : 1, "number" : 0 } } {code}
    via by Thomas Darimont,
  • After migrating Spring Data application from Gosling-SR4 to Hopper-SR1 release, all custom queries that extends JpaRepository throws the following message: {code:java} Caused by: java.lang.IllegalStateException: No aliases found in result tuple! Make sure your query defines aliases! at org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter.convert(AbstractJpaQuery.java:246) [spring-data-jpa-1.10.1.RELEASE.jar:] at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:185) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.data.repository.query.ResultProcessor$ChainingConverter$1.convert(ResultProcessor.java:173) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.data.repository.query.ResultProcessor$ChainingConverter.convert(ResultProcessor.java:185) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.data.repository.query.ResultProcessor.processResult(ResultProcessor.java:142) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:107) [spring-data-jpa-1.10.1.RELEASE.jar:] at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:92) [spring-data-jpa-1.10.1.RELEASE.jar:] at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460) [spring-data-commons-1.12.1.RELEASE.jar:] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136) [spring-tx-4.2.5.RELEASE.jar:4.2.5.RELEASE] ... 113 more {code} {code:java} public interface UserProfileAccessGroupRepository extends JpaRepository<UserProfileAccessGroup, UserProfileAccessGroupPK> { @Modifying @Query("DELETE FROM UserProfileAccessGroup upag WHERE upag.id.accessGroup = ?1") public void deleteByAccessGroup(AccessGroup accessGroup); @Modifying @Query("DELETE FROM UserProfileAccessGroup upag WHERE upag.id.userProfile = ?1") public void deleteByUserProfile(UserProfile userProfile); @Query("SELECT upag.id.accessGroup FROM UserProfileAccessGroup upag WHERE upag.id.userProfile = ?1") public List<AccessGroup> findAccessGroupByUserProfile(UserProfile userProfile); @Query("SELECT upag.id.accessGroup FROM UserProfileAccessGroup upag WHERE upag.id.userProfile = ?1 AND upag.id.accessGroup.functionality = false") public List<AccessGroup> findGroupByUserProfile(UserProfile userProfile); public List<UserProfileAccessGroup> findByExpirationDateBefore(Date date); } {code} {code:java} @Entity public class UserProfileAccessGroup implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId private UserProfileAccessGroupPK id; private Date expirationDate; @ManyToOne @JoinColumn(name = "authorizedBy") private UserProfile authorizedBy; public UserProfileAccessGroupPK getId() { if (id == null) { id = new UserProfileAccessGroupPK(); } return id; } public void setId(UserProfileAccessGroupPK id) { this.id = id; } public Date getExpirationDate() { return expirationDate; } public void setExpirationDate(Date expirationDate) { this.expirationDate = expirationDate; } public UserProfile getAuthorizedBy() { return authorizedBy; } public void setAuthorizedBy(UserProfile authorizedBy) { this.authorizedBy = authorizedBy; } @Embeddable public static class UserProfileAccessGroupPK implements Serializable { private static final long serialVersionUID = 1L; @ManyToOne @JoinColumn(name = "accessGroupId") private AccessGroup accessGroup; @ManyToOne @JoinColumn(name = "userProfileId") private UserProfile userProfile; public UserProfileAccessGroupPK() { } public UserProfileAccessGroupPK(AccessGroup accessGroup, UserProfile userProfile) { this.accessGroup = accessGroup; this.userProfile = userProfile; } public AccessGroup getAccessGroup() { return accessGroup; } public void setAccessGroup(AccessGroup accessGroup) { this.accessGroup = accessGroup; } public UserProfile getUserProfile() { return userProfile; } public void setUserProfile(UserProfile userProfile) { this.userProfile = userProfile; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((accessGroup == null) ? 0 : accessGroup.hashCode()); result = prime * result + ((userProfile == null) ? 0 : userProfile.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; UserProfileAccessGroupPK other = (UserProfileAccessGroupPK) obj; if (accessGroup == null) { if (other.accessGroup != null) return false; } else if (!accessGroup.equals(other.accessGroup)) return false; if (userProfile == null) { if (other.userProfile != null) return false; } else if (!userProfile.equals(other.userProfile)) return false; return true; } } } {code}
    via by ofbiz,
  • GitHub comment 1#164110202
    via GitHub by washawu
    ,
  • Hey there, here is some code which fails in gradle but works in eclipse and by calling the resource by an other service from outside. I would really appreciate some help on this. Is there also a way to come around marking SimpleAggregation as an Entity? At the moment it will be created in the database but I just need it for aggregational purpose. I tried some with projections (define it as an interface) and and also with EnableMapRepositories, but was not able to get it work. gradlew: 2.13 spring-boot: 1.3.5 {code} 2016-05-19 14:49:12.000 ERROR 12584 --- [o-auto-1-exec-5] o.s.d.r.w.RepositoryRestExceptionHandler : PersistentEntity must not be null! java.lang.IllegalArgumentException: PersistentEntity must not be null! at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.<init>(PersistentEntityResource.java:140) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.<init>(PersistentEntityResource.java:123) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.PersistentEntityResource.build(PersistentEntityResource.java:115) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.wrap(PersistentEntityResourceAssembler.java:74) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:55) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.entitiesToResources(AbstractRepositoryRestController.java:133) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.toResources(AbstractRepositoryRestController.java:80) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.toResource(AbstractRepositoryRestController.java:100) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:183) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_40] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_40] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_40] at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_40] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:832) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:743) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458) [tomcat-embed-core-8.0.33.jar:8.0.33] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_40] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_40] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.33.jar:8.0.33] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40] {code} {code:title=SimpleAggregation.java|borderStyle=solid} @Entity @Getter @Setter public class SimpleAggregation implements Persistable<Long> { private static final long serialVersionUID = -5092557881988049420L; public SimpleAggregation() {} public SimpleAggregation(String category, BigDecimal value) { this.category = category; this.value = value; } @Id private Long id = 0L; private String category; private BigDecimal value; @Override public boolean isNew() { // TODO Auto-generated method stub return false; } @Override public Long getId() { // TODO Auto-generated method stub return null; } } {code} {code:title=BookingRepository.java|borderStype=solid} @Transactional @RepositoryRestResource(collectionResourceRel = "booking", path = "booking") public interface BookingRepository extends JpaRepository<Booking, Long> { @Query("SELECT new lessor.persistence.SimpleAggregation(Concat(b.bookingDate) AS category, Coalesce(SUM(b.value),0) AS value) " + "FROM Booking b INNER JOIN b.rentalProperty rp INNER JOIN rp.account a " + "WHERE b.bookingDate BETWEEN :fromDate AND :toDate " + " AND (b.rentalProperty.itemId = :rentalPropertyId OR :rentalPropertyId IS NULL) " + " AND (b.bookingClass.itemId = :bookingClassId OR :bookingClassId IS NULL) " + " AND a.itemId = :accountId " + "GROUP BY b.bookingDate " + "ORDER BY b.bookingDate") List<SimpleAggregation> aggregateBookingValuePerBookingDay(@Param("accountId") Long accountId, @Param("rentalPropertyId") Long rentalPropertyId , @Param("bookingClassId") Long bookingClassId , @DateTimeFormat(iso=ISO.DATE, pattern="yyyy-MM-dd")@Param("fromDate") LocalDate fromDate , @DateTimeFormat(iso=ISO.DATE, pattern="yyyy-MM-dd")@Param("toDate") LocalDate toDate); } {code} Code to excecute within my integration test looks like this: {code} String url = bookingSearchAggregateBookingValuePerBookingDay + "?" + "accountId=" + EXPECTED_ACCOUNT_ID + "&fromDate=" + EXPECTED_BOOKING_SEARCH_FROM_DATE + "&toDate=" + EXPECTED_BOOKING_SEARCH_TILL_DATE; RequestEntity<Void> request = RequestEntity.get(URI.create(url)) .accept(MediaTypes.HAL_JSON).acceptCharset(Charset.forName("UTF-8")).build(); ResponseEntity<Resources<SimpleAggregation>> bookingResourcesEntity = restTemplate.exchange(request, new ParameterizedTypeReference<Resources<SimpleAggregation>>() {}); {code} Thanks for your help!
    via by Karsten Ludwig Hauser,
  • Error Spring Data Neo4j in docker image
    via Stack Overflow by Primael Bruant
    ,
  • Hey there, here is some code which fails in gradle but works in eclipse and by calling the resource by an other service from outside. I would really appreciate some help on this. Is there also a way to come around marking SimpleAggregation as an Entity? At the moment it will be created in the database but I just need it for aggregational purpose. I tried some with projections (define it as an interface) and and also with EnableMapRepositories, but was not able to get it work. gradlew: 2.13 spring-boot: 1.3.5 {code} 2016-05-19 14:49:12.000 ERROR 12584 --- [o-auto-1-exec-5] o.s.d.r.w.RepositoryRestExceptionHandler : PersistentEntity must not be null! java.lang.IllegalArgumentException: PersistentEntity must not be null! at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.<init>(PersistentEntityResource.java:140) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.<init>(PersistentEntityResource.java:123) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.PersistentEntityResource.build(PersistentEntityResource.java:115) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.wrap(PersistentEntityResourceAssembler.java:74) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:55) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.entitiesToResources(AbstractRepositoryRestController.java:133) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.toResources(AbstractRepositoryRestController.java:80) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.toResource(AbstractRepositoryRestController.java:100) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:183) ~[spring-data-rest-webmvc-2.5.1.RELEASE.jar:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_40] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_40] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_40] at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_40] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) ~[spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:832) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:743) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895) ~[spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:843) [spring-webmvc-4.2.6.RELEASE.jar:4.2.6.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) [tomcat-embed-websocket-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-4.2.6.RELEASE.jar:4.2.6.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502) [tomcat-embed-core-8.0.33.jar:8.0.33] at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458) [tomcat-embed-core-8.0.33.jar:8.0.33] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_40] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_40] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.33.jar:8.0.33] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_40] {code} {code:title=SimpleAggregation.java|borderStyle=solid} @Entity @Getter @Setter public class SimpleAggregation implements Persistable<Long> { private static final long serialVersionUID = -5092557881988049420L; public SimpleAggregation() {} public SimpleAggregation(String category, BigDecimal value) { this.category = category; this.value = value; } @Id private Long id = 0L; private String category; private BigDecimal value; @Override public boolean isNew() { // TODO Auto-generated method stub return false; } @Override public Long getId() { // TODO Auto-generated method stub return null; } } {code} {code:title=BookingRepository.java|borderStype=solid} @Transactional @RepositoryRestResource(collectionResourceRel = "booking", path = "booking") public interface BookingRepository extends JpaRepository<Booking, Long> { @Query("SELECT new lessor.persistence.SimpleAggregation(Concat(b.bookingDate) AS category, Coalesce(SUM(b.value),0) AS value) " + "FROM Booking b INNER JOIN b.rentalProperty rp INNER JOIN rp.account a " + "WHERE b.bookingDate BETWEEN :fromDate AND :toDate " + " AND (b.rentalProperty.itemId = :rentalPropertyId OR :rentalPropertyId IS NULL) " + " AND (b.bookingClass.itemId = :bookingClassId OR :bookingClassId IS NULL) " + " AND a.itemId = :accountId " + "GROUP BY b.bookingDate " + "ORDER BY b.bookingDate") List<SimpleAggregation> aggregateBookingValuePerBookingDay(@Param("accountId") Long accountId, @Param("rentalPropertyId") Long rentalPropertyId , @Param("bookingClassId") Long bookingClassId , @DateTimeFormat(iso=ISO.DATE, pattern="yyyy-MM-dd")@Param("fromDate") LocalDate fromDate , @DateTimeFormat(iso=ISO.DATE, pattern="yyyy-MM-dd")@Param("toDate") LocalDate toDate); } {code} Code to excecute within my integration test looks like this: {code} String url = bookingSearchAggregateBookingValuePerBookingDay + "?" + "accountId=" + EXPECTED_ACCOUNT_ID + "&fromDate=" + EXPECTED_BOOKING_SEARCH_FROM_DATE + "&toDate=" + EXPECTED_BOOKING_SEARCH_TILL_DATE; RequestEntity<Void> request = RequestEntity.get(URI.create(url)) .accept(MediaTypes.HAL_JSON).acceptCharset(Charset.forName("UTF-8")).build(); ResponseEntity<Resources<SimpleAggregation>> bookingResourcesEntity = restTemplate.exchange(request, new ParameterizedTypeReference<Resources<SimpleAggregation>>() {}); {code} Thanks for your help!
    via by Karsten Ludwig Hauser,
  • JPARepository return single field only
    via Stack Overflow by apurv
    ,
    • java.lang.IllegalArgumentException: PersistentEntity must not be null! at org.springframework.util.Assert.notNull(Assert.java:112) at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.<init>(PersistentEntityResource.java:155) at org.springframework.data.rest.webmvc.PersistentEntityResource$Builder.<init>(PersistentEntityResource.java:137) at org.springframework.data.rest.webmvc.PersistentEntityResource.build(PersistentEntityResource.java:129) at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.wrap(PersistentEntityResourceAssembler.java:105) at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:84) at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.toResource(PersistentEntityResourceAssembler.java:45) at org.springframework.data.web.PagedResourcesAssembler.createResource(PagedResourcesAssembler.java:137) at org.springframework.data.web.PagedResourcesAssembler.toResource(PagedResourcesAssembler.java:96) at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.entitiesToResources(AbstractRepositoryRestController.java:228) at org.springframework.data.rest.webmvc.AbstractRepositoryRestController.resultToResources(AbstractRepositoryRestController.java:215) at org.springframework.data.rest.webmvc.RepositorySearchController.executeQueryMethod(RepositorySearchController.java:291) at org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(RepositorySearchController.java:175) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:777) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:706) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:943) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857) at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:744)

    Users with the same issue

    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    Unknown visitor
    Unknown visitor1 times, last one,
    osvzsosvzs
    2 times, last one,
    oddodd
    2 times, last one,
    189 more bugmates