Skip to content

Sorting and limits are ignored #585

@cdprete

Description

@cdprete

Hello.

In one of my applications using Spring Boot 3.5.7 (and grabbing its dependencies from the BoM), I tried to define an LdapRepository as follows:

@Validated
@Entry(base = "tkfdomtyp=109", objectClasses = "tkfdomain.gzip")
public final class AdjustmentFactorLdapEntry {
    @Id
    @NotNull
    private Name domain;

    @NotBlank
    @Attribute(name = "domain-name")
    private String domainName;

    @NotEmpty
    @Attribute(name = "domain;binary", type = BINARY)
    private byte[] data;

    @Attribute(name = "svn-revision")
    private int revision;

    public Name getDomain() {
        return domain;
    }

    public void setDomain(Name domain) {
        this.domain = domain;
    }

    public String getDomainName() {
        return domainName;
    }

    public void setDomainName(String domainName) {
        this.domainName = domainName;
    }

    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }

    public int getRevision() {
        return revision;
    }

    public void setRevision(int revision) {
        this.revision = revision;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof AdjustmentFactorLdapEntry gmsEntity)) return false;
        return Objects.equals(domain, gmsEntity.domain);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(domain);
    }
}

public interface AdjustmentFactorLdapRepository extends LdapRepository<AdjustmentFactorLdapEntry> {
    Optional<AdjustmentFactorLdapEntry> findFirstByDomainNameOrderByRevisionDesc(String domainName);
}

with the assumption that only the first newest entry would be returned, but actually I get:

  • all the results back instead of only one, making therefore the code fail
  • the sorting gets completely ignored

Am I missing something or is indeed such a feature not supported?
Debugging org.springframework.data.ldap.repository.query.LdapQueryExecution.FindOneExecution which gets called, I can see no limits no sorts attribute being passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions