-
Hello, we are using R2dbc and have an entity similar to this: @MappedEntity("entity")
data class Entity(
val name: String,
@field:Id val id: Long? = null
) {
@Relation(Relation.Kind.MANY_TO_ONE) var relationshipOne: RelationOne? = null
@Relation(Relation.Kind.MANY_TO_ONE) var relationshipTwo: RelationTwo? = null
} The idea here is that one operation can initialize and save the Entity, another operation sets relationshipOne, and another operation sets relationshipTwo. We do this by doing: val entity = entityRepository.findBy(id)
entity.relationshipOne = RelationshipOne(...)
entityRepository.update(entity) However, when we do this again in a second place: val entity = entityRepository.findBy(id)
entity.relationshipTwo = RelationshipTwo(...)
entityRepository.update(entity) The update statement generated sets relationship_one_id to null. It seems like the issue is because we don't have @Join annotations on the Repository, so the Entity that gets loaded has relationshipOne and relationshipTwo set to null. We worked around this for now by removing the Relation declarations, but that's not ideal obviously. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You can use something like |
Beta Was this translation helpful? Give feedback.
You can use something like
update(@Id Long id, RelationshipOne relationshipOne)
which will update only one field.