Skip to content

Spring Data projection with LocalDate not working anymore [DATAJPA-1833] #2121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Dec 13, 2020 · 3 comments
Assignees
Labels
in: core Issues in core support status: duplicate A duplicate of another issue type: bug A general bug

Comments

@spring-projects-issues
Copy link

hugograf opened DATAJPA-1833 and commented

If have a Interface like the following:

 public interface IDateAndClose {
  @JsonFormat(pattern = GlobalConstants.STANDARD_DATE_FORMAT)
  @Schema(description = "Date of close")
  LocalDate getDate();
  
  @Schema(description = "Close price")
  Double getClose();
}

It seems the Spring Data projection with LocaDate is not working anymore. I would work with java.util.date and it worked well until Spring Boot 2.3.7. Since Spring Boot 2.4.X a get an error like the following:

 

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Projection type must be an interface! (through reference chain: java.util.ArrayList[0]->com.sun.proxy.$Proxy278["date"])Caused by: com.fasterxml.jackson.databind.JsonMappingException: Projection type must be an interface! (through reference chain: java.util.ArrayList[0]->com.sun.proxy.$Proxy278["date"]) at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:397) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:356) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:316) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:763) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:178) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serializeContents(CollectionSerializer.java:145) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:107) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.ser.std.CollectionSerializer.serialize(CollectionSerializer.java:25) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:400) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1512) ~[jackson-databind-2.11.3.jar:2.11.3] at com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:1006) ~[jackson-databind-2.11.3.jar:2.11.3] at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:345) ~[spring-web-5.3.2.jar:5.3.2] ... 79 common frames omittedCaused by: java.lang.IllegalArgumentException: Projection type must be an interface! at org.springframework.util.Assert.isTrue(Assert.java:121) ~[spring-core-5.3.2.jar:5.3.2] at org.springframework.data.projection.ProxyProjectionFactory.createProjection(ProxyProjectionFactory.java:105) ~[spring-data-commons-2.4.2.jar:2.4.2] at org.springframework.data.projection.SpelAwareProxyProjectionFactory.createProjection(SpelAwareProxyProjectionFactory.java:45) ~[spring-data-commons-2.4.2.jar:2.4.2] at org.springframework.data.projection.ProjectingMethodInterceptor.getProjection(ProjectingMethodInterceptor.java:160) ~[spring-data-commons-2.4.2.jar:2.4.2] at org.springframework.data.projection.ProjectingMethodInterceptor.potentiallyConvertResult(ProjectingMethodInterceptor.java:108) ~[spring-data-commons-2.4.2.jar:2.4.2] at org.springframework.data.projection.ProjectingMethodInterceptor.invoke(ProjectingMethodInterceptor.java:85) ~[spring-data-commons-2.4.2.jar:2.4.2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.2.jar:5.3.2] at org.springframework.data.projection.ProxyProjectionFactory$TargetAwareMethodInterceptor.invoke(ProxyProjectionFactory.java:250) ~[spring-data-commons-2.4.2.jar:2.4.2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.2.jar:5.3.2] at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:80) ~[spring-data-commons-2.4.2.jar:2.4.2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.2.jar:5.3.2] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) ~[spring-aop-5.3.2.jar:5.3.2] at com.sun.proxy.$Proxy278.getDate(Unknown Source) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]  

 


Issue Links:

  • DATACMNS-1836 Native projection stopped working with Java8 datetime
    ("duplicates")
@spring-projects-issues spring-projects-issues added type: bug A general bug in: core Issues in core support status: duplicate A duplicate of another issue labels Dec 30, 2020
@prabhugopal
Copy link

Is this issue already fixed & closed?

We recently upgraded to 2.4.5 from 2.3.7, and we still see this issue exists. In our situation we have got entities with attributes of type LocalDateTime & the projection attributes with LocalDate.

The projection fails with below exception

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Projection type must be an interface! (through reference chain ***

I checked the status of fix in here https://jira.spring.io/browse/DATACMNS-1836 but the status says "Waiting for Review" does it mean it still open & verification state?

@schauder
Copy link
Contributor

schauder commented May 5, 2021

This issue is closed as a duplicate. The issue it references is closed as fixed in version 2.4.3. If you still see the problem with that or a later version please create a new issue.

@prabhugopal
Copy link

This issue is closed as a duplicate. The issue it references is closed as fixed in version 2.4.3. If you still see the problem with that or a later version please create a new issue.

Thanks @schauder let me create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core support status: duplicate A duplicate of another issue type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants