Giter Club home page Giter Club logo

Comments (5)

shubham-aggarwal avatar shubham-aggarwal commented on May 24, 2024 3

Just specifying repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class in my Application class did the trick.

from spring-data-jpa-datatables.

tomcgn avatar tomcgn commented on May 24, 2024 2

Hi Damien,
Thanks for the quick response. And for the very good work!

Sure, I didn't miss the inheritance so the reason was something else.

The autowiring of the existing repositories failed, if the application is configured to use @EnableJpaRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class) for all repos.
The solution is to create new repos that extend the exisiting ones, in a distinct package - anyways a good idea to keep existing api stable, and have these repositories interfaces extend the DataTablesRespository, as you suggest.

Then, you can specify that package in Application.java @EnableJpaRepositories(repositoryFactoryBeanClass = DataTablesRepositoryFactoryBean.class, basePackages = "org.whatever.repository.datatables")
Then the differing factory is only applied to the repositories responsible for datatables.

Sorting and paging works fine now.
I will continue tomorrow with the search, which does not yet work (it's supported, right?)

Thanks again for sharing this, it was definitely missing and is worth a mention on datatables.net

from spring-data-jpa-datatables.

darrachequesne avatar darrachequesne commented on May 24, 2024

Hi! Glad you find it useful! Don't hesitate if you find something is missing.

My first guess is that your MeetingRepository should extend DataTablesRepository (which itself extends PagingAndSortingRepository). The findAll method is defined there https://github.com/darrachequesne/spring-data-jpa-datatables/blob/master/src/main/java/org/springframework/data/jpa/datatables/repository/DataTablesRepository.java#29

Cheers

from spring-data-jpa-datatables.

darrachequesne avatar darrachequesne commented on May 24, 2024

Well, it seems my answer was, if quick, not really useful 😄

Your solution is great, I think it's worth a mention in the readme! You could also create your own RepositoryFactory (disclaimer: your solution is cleaner):

private static class YourCustomRepositoryFactory<T, ID extends Serializable>
            extends JpaRepositoryFactory {
        [...]

        @SuppressWarnings({ "unchecked" })
        protected Object getTargetRepository(RepositoryMetadata metadata) {
            JpaEntityInformation<T, Serializable> entityInformation = (JpaEntityInformation<T, Serializable>) getEntityInformation(metadata
                    .getDomainType());
            Class<?> repositoryInterface = metadata.getRepositoryInterface();

            return DataTablesRepository.class.isAssignableFrom(repositoryInterface)
                    ? new DataTablesRepositoryImpl<T, ID>(entityInformation, entityManager)
                    : <your other implementation here>;
        }
    }

PS: search should be working, maybe some column must be set with searchable: false on the client-side (yet another clueless guess!).

Cheers

from spring-data-jpa-datatables.

tomcgn avatar tomcgn commented on May 24, 2024

Well, your last one was, if only I followed your advice:
Live seach works as intended if disable searching on all except one coiumn!
That will do for the moment, thanks again :)
I will leave the other issue open, as it adresses a slightly different topic (search on all filed of an entitiy rather than on one column/member of the model class.
Cheers

from spring-data-jpa-datatables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.