rsql-jpa-specification icon indicating copy to clipboard operation
rsql-jpa-specification copied to clipboard

Using distinct creating the specification fails with composite keys

Open thmasker opened this issue 1 year ago • 1 comments

Hi,

I just found out that for entities with composite keys, the generated query fails. For instance:

@Entity
@Table(name = "offices")
public class Office implements Serializable {

    @EmbeddedId
    private OfficeId id;

    ...

    @Embeddable
    @EqualsAndHashCode
    public static class OfficeId implements Serializable {

        @Column(name = "entity")
        private String entity;

        @Column(name = "code")
        private String office;

    }

}

This entity will generate the following query when using pagination:

select distinct count(distinct office0_.entity, office0_.code) as col_0_0_ 
from offices office0_

which obviously fails in Oracle since count does not support two arguments...

thmasker avatar Jul 21 '23 10:07 thmasker