spring-data-relational
spring-data-relational copied to clipboard
Nested @MappedCollection is not loaded correctly with UUID primary key
This problem is found in spring-data-jdbc version 3.2 It is still present in version 3.2.5.
Code example:
data class Foo( @Id val id: UUID = UUID.randomUUID(), @MappedCollection(idColumn = "foo_id") val bar: Bar, // If this is changes to Set<Bar> the test run OK. )
data class Bar(
@Id
val id: UUID = UUID.randomUUID(),
@MappedCollection(idColumn = "bar_id")
val barItem: Set<BarItem>,
)
data class BarItem(
@Id
val id: UUID = UUID.randomUUID(),
val description: String
)
@Autowired
lateinit var entityOperations: JdbcAggregateOperations
@Test
fun fooTest() {
val foo = entityOperations.insert(Foo(bar = Bar(barItem = setOf(BarItem(description = "not null")))))
val fooFromDb = entityOperations.findById(foo.id, Foo::class.java)
val barItemFromDb = entityOperations.findById(foo.bar.barItem.first().id, BarItem::class.java)
barItemFromDb!!.description shouldBe "not null" // This part runs ok, so item is correctly persisted
fooFromDb!!.bar.barItem.first().description shouldBe "not null" // This part fails, barItem is an empty collection.
}
In our project all db keys are uuid. If I change all primary keys in this example with Long the test run OK. If I downgrade to version 3.1.11 the test runs OK.
This sounds similar to #1684. Can you run your test against the most recent snapshot build?
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.