You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
r2dbc: insert() operation does not work properly when the id is wrapped in a data class #1407
So far so good.
now i want to refactor my entity's id to be a data class. for example:
before:
@Table("messages")
data classMessageEntity(
@Id
@Column("id")
valid:Int = 0,
}
after:
data classMessageId(privatevalvalue:Int) {
funtoInt() = value
overridefuntoString(): String= value.toString()
}
@Table("messages")
data classMessageEntity(
@Id
@Column("id")
valid:MessageId = MessageId(0)
}
Now whenever i save something with above save() function it does not return the write result like before (i.e. the id which is on purpose 0 does not get returned with the actual value). But the entity is saved properly in db with proper (auto-increased) id, meaning if i search for it the result is correct.
Additional info
Note: i have custom @WritingConverter & @ReadingConverter for this entity:
Note 2:
I searched through other issues and i found spring-projects/spring-data-r2dbc#49 and #218. I think my case is different from them since my entity is actual saved in db properly and with proper id.
Thank you for the answer. I'm not familiar with composite identifiers, is there any issue/link/doc for this (i searched the issues and could not find one)?
You can follow #1276 for the composite primary key feature. Wrapping the primary key value in a different type creates a composite key type because the identifier type no longer matches a supported primitive type.
Activity
mp911de commentedon Jan 9, 2023
Composite Identifiers (that is what this boils down to) are not yet supported.
GeorgePap-719 commentedon Jan 9, 2023
Thank you for the answer. I'm not familiar with composite identifiers, is there any issue/link/doc for this (i searched the issues and could not find one)?
mp911de commentedon Jan 9, 2023
You can follow #1276 for the composite primary key feature. Wrapping the primary key value in a different type creates a composite key type because the identifier type no longer matches a supported primitive type.
mp911de commentedon Jan 9, 2023
Closing as a duplicate for the time being.