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.

Add query derivation for delete queries [DATAJDBC-551]

See original GitHub issue

rod2j opened DATAJDBC-551 and commented

Derived delete/removeByXxx queries work as expected for return type void but fail when return type is long/Long or List<entity type>, where it should return the number of records or the list of entities actually deleted:

instead I get

org.springframework.aop.AopInvocationException: Null return value from advice does not match primitive return type for: public abstract long 

it also appears the generated SQL query is actually a SELECT instead of a DELETE whenever the derived delete query has a non void return type.


Affects: 2.0 GA (Neumann)

Issue Links:

  • DATAJDBC-568 Derived delete query throws IncorrectResultSetColumnCountException (“is duplicated by”)

Referenced from: pull request https://github.com/spring-projects/spring-data-jdbc/pull/230

2 votes, 7 watchers

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

4reactions
spring-projects-issuescommented, Dec 31, 2020

Mark Paluch commented

Thanks for reporting the issue. Derived delete queries are not yet supported

2reactions
spring-projects-issuescommented, Dec 31, 2020

Rob Maskell commented

I tried a derived delete query with a void return type and this exception was thrown

org.springframework.data.mapping.model.MappingInstantiationException: Failed to instantiate void using constructor NO_CONSTRUCTOR with arguments 

The repository method signature was

void deleteByEventId(Long eventId);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Derived delete query throws ...
JdbcTemplate.query(JdbcTemplate.java:669) ~[spring-jdbc-5.2.7.RELEASE.jar!/:5.2.7. ... DATAJDBC-551 Add query derivation for delete queries
Read more >
Spring Data JPA - Derived Delete Methods - Baeldung
Spring Data JPA allows us to define derived methods that read, update or delete records from the database. This is very helpful as...
Read more >
Spring Data: "delete by" is supported? - Stack Overflow
In modern versions of Spring Data JPA (>=1.7.x) query derivation for delete ... Derivation of delete queries using given method name is supported...
Read more >
Derived Queries with Spring Data JPA – The Ultimate Guide
You can let Spring Data JPA derive the query from the name of a method in your repository. You can define your own...
Read more >
Spring Data JPA - Reference Documentation
... query derivation for both count and delete queries is available. ... This prevents Spring Data to try to create an instance of...
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