Skip to content

Type Mismatch Error for embedded object with generics in ids #262

@dimitrisLas

Description

@dimitrisLas

Hello,

The specifications result on type mismatch in scenarios like the following:
We have 2 entities:

@Entity
class Entity1 (
    var name: String
): IdEntity<Long>()

and

@Entity
@Table
class Entity2(
    @ManyToOne(cascade = [CascadeType.ALL])
    val entity1: Entity1,

    val name: String
): IdEntity<UUID>()

Then using the following endpoint we get a DateTimeParseException even thought the type is long.

@GetMapping
    fun getEntity2(
        pageable: Pageable,
        @And(
            Spec(path="entity1.id", params = ["entity1Id"], onTypeMismatch = OnTypeMismatch.EXCEPTION, spec = Equal::class),
            Spec(path = "name", spec = LikeIgnoreCase::class)
        )
        searchSpecification: Specification<Entity2>?
    ): ResponseEntity<Page<Entity2>> =
        ResponseEntity.ok(entity2Repository.findAll(searchSpecification, pageable))

To reproduce the issue I created the following simple project

The issue can be verified either by:

  • Posting for example the following to /entity2 and the performing a get request to entity2?entity1Id=1:
{
    "entity1": {
        "name": "entity-1-test"
    },
    "name": "entity-2-test"
}
  • Running the tests. Ideally the should all pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions