I try declare and use deleteBy method with spring-data-jdbc repositories like this
public interface TokenRepository extends CrudRepository<OpToken, Long> {
void deleteByBreed(Long breed);
}
When i tried to call method
private TokenRepository tokenRepository;
...
...
tokenRepository.deleteByBreed(123L);
I got exception: MethodNotFoundException:
java.lang.NoSuchMethodException: void.()
I decided, that delete method should return number of rows it processed. So, i rewrite my repository interface like this
public interface TokenRepository extends CrudRepository<OpToken, Long> {
long deleteByBreed(Long breed);
}
But now i have got another exception: org.springframework.jdbc.IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 4
It's looks like method return entity or list of entities it try to delete. But i do not need them. How can i declare this method in my case?
By Entity looks like this:
@Data
public class OpToken implements Persistable<Long> {
@Transient
private boolean newEntity;
@Id
@Column("jti")
private Long jti;
@Column("breed")
private Long breed;
@Column("id_account")
private Long idAccount;
@Column("exp")
private Date exp;
@Override
public Long getId() {
return jti;
}
@Override
public boolean isNew() {
return newEntity;
}
}