Skip to content

Issue with CursoredPageable and @EmbeddedId #3407

@cutz

Description

@cutz

Expected Behavior

I'm running into an issue trying to use CursoredPageable on a repository whose entity is keyed by a complex primary key modeled as an @EmbeddedId . For example:

@Embeddable
public record AssetId(
        @MappedProperty("container_id")
        UUID containerId,
        @MappedProperty("asset_id")
        Integer assetId
) {
}

@MappedEntity("assets")
public record EphemeralAsset(
    @EmbeddedId
    AssetId id
){}

@JdbcRepository(dialect =  Dialect.POSTGRES)
public interface EphemeralAssetsRepository extends PageableRepository<EphemeralAsset, AssetId> {

    CursoredPage<EphemeralAsset> findByIdContainerId(UUID containerId, CursoredPageable pageable);
}

When invoking findByContainerId the generated query tries to add a sort clause for assets.id which is a column that does not exist. I think the EmbeddedId should be expanded to sort clauses for both assets.container_id and assets.asset_id. Is this a bug in Micronaut Data query generation or a misunderstanding on how EmbeddedId should be working?

Actual Behaviour

When invoking findByContainerId the generated query tries to add a sort clause for assets.id which is a column that does not exist.

Steps To Reproduce

No response

Environment Information

No response

Example Application

Example Application

Version

4.8.2

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions