I am following this tutorial Spring Boot MongoDB Pagination example with Spring Data
And I am wondering if there is a way to make the java code generic
So I can use this code for all my collections without the need to create the POJOs’
for example
in the code he is building the Tutorial Pojo:
public interface TutorialRepository extends MongoRepository<Tutorial, String> {
Page<Tutorial> findByPublished(boolean published, Pageable pageable);
Is there a way to make the code generic so it will get a collection name, and perform paging, filtering / sorting without the need to create the Pojos?
In the past we had DBObject, Is it still a thing?
for example:
public interface GenericRepository extends MongoRepository<T, String> {
Page<DBObject?> findXYZ(String mongoCollectionName ,Filter filter, Pageable pageable);
I just need the JSON without specifying each and every java object, because there are too many collections.
Thank you!