Issue
Given the following entity/table defined in a Spring/KotlinCoroutines project.
@Table("workers")
data class Worker(
@Id
val id: UUID? = null,
@Column(value = "photo")
var photo: String? = null,
// see: https://github.com/spring-projects/spring-data-r2dbc/issues/449
@Transient
@Value("#{root.photo!=null}")
val hasPhoto: Boolean = false
)
The hasPhoto
field does not map to a table field. I follow the R2dbc official reference doc and use a Spring EL to evaluate the EL result as value of this field.
But when I test this hasPhoto
, it always returns false even I set the photo to a nonnull string.
Solution
Got answer from the Spring guys, @Value
here only can access the projection.
Answered By - Hantsy
Answer Checked By - Timothy Miller (JavaFixing Admin)