You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try implementing a repository using Spring Data JDBC as described in the documentation, using an (embedded) HSQL database.
When using derived delete queries (see Example 6 in the linked documentation), I encounter two issues:
When trying to return the number of deleted records (domain class com.example.demo.db.User), I get a ClassCastException (java.lang.ClassCastException: com.example.demo.db.User cannot be cast to java.lang.Long).
When using a query with either void or with the domain object as return type, the method successfully completes, but the record is never deleted. It looks like only a SELECT statement is performed on the database, but not the DELETE statement.
It doesn't matter if I try to remove by id or by a custom attribute of my entity.
The default void deleteById(Integer id) method and using custom queries (with the @Query annotation) both works.
For other queries (e.g. findByUsername) everything seems to work.
I have created a minimal reproducer to showcase the problem: when running the com.example.demo.db.UserRepositoryTest class, the tests using the default method or the explicit query methods (those with @Query) work, but those with the derived queries fail.
Is this a bug or do I misunderstand/misconfigure something?
The text was updated successfully, but these errors were encountered:
Hi @schauder I also saw this issue but there it is stated that
Derived delete/removeByXxx queries work as expected for return type void
which isn't the case in my example. And the exception for long return value was also different.
But I guess #771 has developed into an accumulative issue regarding this? Maybe as long as #771 isn't fixed, there should be a note in the documentation, that the given examples actually aren't working...
I try implementing a repository using Spring Data JDBC as described in the documentation, using an (embedded) HSQL database.
When using derived delete queries (see Example 6 in the linked documentation), I encounter two issues:
com.example.demo.db.User
), I get a ClassCastException (java.lang.ClassCastException: com.example.demo.db.User cannot be cast to java.lang.Long
).SELECT
statement is performed on the database, but not theDELETE
statement.It doesn't matter if I try to remove by id or by a custom attribute of my entity.
The default
void deleteById(Integer id)
method and using custom queries (with the@Query
annotation) both works.For other queries (e.g.
findByUsername
) everything seems to work.I have created a minimal reproducer to showcase the problem: when running the
com.example.demo.db.UserRepositoryTest
class, the tests using the default method or the explicit query methods (those with@Query
) work, but those with the derived queries fail.Is this a bug or do I misunderstand/misconfigure something?
The text was updated successfully, but these errors were encountered: