#Pagination

3 messages · Page 1 of 1 (latest)

earnest narwhal
#

I'm trying to make filter by 'result', I mean I have a class Calculation and a lot of subclasses for example entity Multiplication, Sum, Division itd.

//lombok
@Entity
@Inheritance
@DiscriminatorColumn(name = "type")
public abstract class Calculation {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

}
//lombok
@Entity
@DiscriminatorValue("SUM")
public class Sum extends Calculation {

    private double firstNumber;
    private double secondNumber;

}

itd.

I want to have in my service class pagination with filtering BY RESULT. I mean if we have in SUM (2 and 3) i want to have somewhere RESULT of this.

    @Override
    public Page<CalculationDto> findAll(Criteria criteria, Pageable pageable) {
        Specification<Calculation> specification = Specification.SpecificationBuilder
                .withResult(criteria.getResult())
                .build();

        return calculationRepository.findAll(specification, pageable)
                .map(CalculationFacade::mapToDto)
                .toList();
    }

And the question is how to do something like this. I was trying do this with @Formula, but it wasnt working for me properly (maybe i was doing this wrong). Maybe i shouldn't use SINGLE_TABLE idk. I just need an idea and a little help.

I want to filter by RESULT of calculation.

violet mirageBOT
#

This post has been reserved for your question.

Hey @earnest narwhal! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.