darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
440 stars 174 forks source link

org.springframework.dao.InvalidDataAccessApiUsageException: object is not an instance of declaring class #132

Open furlatq opened 2 years ago

furlatq commented 2 years ago

Hi, I'm facing the following error and just can't figure out what's the solution for it... I made all configuration like specified but seems that my JPA context is not getting the right class for DataTablesRepository.

Here's what I have:

My repository context xml:

<jpa:repositories factory-class="org.springframework.data.jpa.datatables.repository.DataTablesRepositoryFactoryBean"
            base-package="br.com.xx.paginated.repository" />
    <jpa:repositories base-package="br.com.xx.repository" />

My repository declaration:

package br.com.xx.paginated.repository;
import org.springframework.data.jpa.datatables.repository.DataTablesRepository;

import br.com.xx.entity.AuditoriaProduto;

public interface AuditoriaProdutoRepository extends DataTablesRepository<AuditoriaProduto, Integer> {
}

My service class:

@Service    
public class AuditoriaProdutoServiceImpl implements AuditoriaProdutoService {

    @Autowired
    private AuditoriaProdutoRepository auditoriaProdutoRepository;

        @Override
    public DataTablesOutput<AuditoriaProduto> findAll(DataTablesInput dti) {
        return auditoriaProdutoRepository.findAll(dti);
    }
}

But when I inspect the repository, it has underlying class of SimpleJPARepository instead of the DataTables repository... then I get the error mentioned.

Any ideas of what I'm missing?