question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When have field with type LocalDateTime in Projection, get Projection type must be an interface! [DATACMNS-1847]

See original GitHub issue

Aiksandr opened DATACMNS-1847 and commented

In Spring boot 2.4.1 & 2.4.0 When use projection with field typed LocalDateTime example public interface Report { UUID getId(); LocalDateTime getCreateDate(); } after fetch it from DB, get exception when try access to LocalDateTime field getCreateDate()

i made sample project, if You run it like usual Spring app, that will throw this exception https://github.com/Aiksandr/spring-jpa-demo

{{Caused by: java.lang.IllegalArgumentException: Projection type must be an interface! at org.springframework.util.Assert.isTrue(Assert.java:121) at org.springframework.data.projection.ProxyProjectionFactory.createProjection(ProxyProjectionFactory.java:105) at org.springframework.data.projection.SpelAwareProxyProjectionFactory.createProjection(SpelAwareProxyProjectionFactory.java:45) at org.springframework.data.projection.ProjectingMethodInterceptor.getProjection(ProjectingMethodInterceptor.java:160) at org.springframework.data.projection.ProjectingMethodInterceptor.potentiallyConvertResult(ProjectingMethodInterceptor.java:108) at org.springframework.data.projection.ProjectingMethodInterceptor.invoke(ProjectingMethodInterceptor.java:85) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)}}

And in previews versions it works ok

This issue already was reproduced in spring boot issue https://github.com/spring-projects/spring-boot/issues/24528)


Reference URL: https://github.com/spring-projects/spring-boot/issues/24528

Issue Links:

  • DATACMNS-1836 Native projection stopped working with Java8 datetime (“duplicates”)

0 votes, 6 watchers

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mp911decommented, Feb 19, 2021

Feel free to file a ticket directly against Spring Data JPA along with a minimal reproducible sample so we can specifically look into that issue. JPA typically returns the appropriate result and with a sample we can trace down the cause.

0reactions
schaudercommented, Mar 15, 2021

@NicklasWallgren please open a new issue, since this on e is closed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"java.lang.IllegalArgumentException: Projection type must be ...
IllegalArgumentException: Projection type must be an interface! I'm trying to use native query because the original query is way to complex to ...
Read more >
Spring Boot Data JPA — Part IV (Projections) - Medium
Interface Based Projections. In this type, we create an interface with only getter methods of properties we want from an entity class.
Read more >
How to persist LocalDate and LocalDateTime with JPA 2.1
You need to implement the AttributeConverter<LocalDate, Date> interface with ... the type of the entity attribute (LocalDate) to the database column type ......
Read more >
Projections/DTOs in Spring Data R2DBC - DZone
With the repository in place, things are pretty straightforward: you either use the standard already-provided interface methods, you write ...
Read more >
The best way to map a projection query to a DTO (Data ...
Learn the best way to map a DTO projection when using JPA and ... If we use the same PostDTO class type introduced...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found