Skip to content

@Embedded.Nullable returns as non-null for null collection property #1737

Closed
@radekjezdik

Description

@radekjezdik

Given an @Embedded.Nullable on a property whose object contains a property with a collection type, e.g. list (backed by a varchar array in the DB), the annotated object is returned non-null even for a null value of this collection.

data class Entity(
    @Embedded.Nullable
    val embedded: EmbeddedObject?
) {
    @Id
    var id: Long? = null
}

data class EmbeddedObject(
    @Column("values")
    val values: List<String>?
)

For a row with values = null, the mapper results in the embedded property being a non-null object, and its property values is null.

I guess this is a bug, as it goes against the documented behavior:

the load strategy for the embedded object if all contained fields yield null values.

which should hold for an embedded with a single collection field yielding a null value.

version: 3.2.2

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions