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

Duplicates items after filtering #142

Closed sebasira closed 1 year ago

sebasira commented 2 years ago

I having and issue with an Entity that has a @ManyToMany association. It's a Store and a StoreCategory many stores can be associated to many categories.

I have an Specification to search (like) the associated categories. And after:

dataTablesOutput = dataTableRepository.findAll(input, allColumnsSpecs);

I have this:

Screen Shot 2022-01-08 at 11 49 42

As you can see i have 2 recordsTotal and 3 recordsFiltered so after filtering I have more records than the total. And as you can see, items 0 and 1 are the same Entity.

What I'm doing to solve this is remove duplicates like this:

List<Integer> listWithDuplicates = Lists.newArrayList(5, 0, 3, 1, 2, 3, 0, 0);
List<Integer> listWithoutDuplicates = new ArrayList<>(
      new LinkedHashSet<>(listWithDuplicates));

Is this a bug or am I doing something wrong?

darrachequesne commented 2 years ago

Hi! Could you please provide a basic example reproducing the issue? You can fork the project here: https://github.com/darrachequesne/spring-data-jpa-datatables-sample/

A few things that I can think of:

Related: https://github.com/darrachequesne/spring-data-jpa-datatables/issues/87

darrachequesne commented 1 year ago

Closed due to inactivity, please reopen if needed.