Skip to content

Nested @MappedCollection is not loaded correctly with UUID primary key #1780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bent-lorentzen opened this issue Apr 26, 2024 · 3 comments
Closed

Comments

@bent-lorentzen
Copy link

bent-lorentzen commented Apr 26, 2024

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 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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 26, 2024
@mp911de
Copy link
Member

mp911de commented Apr 26, 2024

This sounds similar to #1684. Can you run your test against the most recent snapshot build?

@mp911de mp911de added the status: waiting-for-feedback We need additional information before we can continue label Apr 26, 2024
@spring-projects-issues
Copy link

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.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label May 3, 2024
@spring-projects-issues
Copy link

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.

@spring-projects-issues spring-projects-issues closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2024
@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants