-
Notifications
You must be signed in to change notification settings - Fork 325
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
Spanner @Embedded annotation doesn't work with findById #774
Comments
Checking this... I was able to reproduce the problem with the sample repository (https://github.com/mixefy/embedded-objects; thanks!):
Memo
Trying to do in Java to see any difference. |
Update: I tried in Java and it worked fine. https://github.com/suztomo/embedded-objects-java
Current status
We haven't figured out why. Next StepsPotential steps I'm thinking:
|
@gaeshi The issue is with the default constructor in Kotlin -- data classes are immutable, so all fields have to be initialized at construction time. Spring Data's In the Java flow, the object is constructed with Java's default constructor, which takes no arguments, allowing Spring Data's object instantiation code to work. The logic for filling in synthetic columns can then be applied. The following entity structure works as expected in Kotlin -- note that this is no longer a data class, and that
|
I'm trying to follow the latest official reference on how to use @Embedded annotation to reuse set of columns between multiple entities:
https://googlecloudplatform.github.io/spring-cloud-gcp/2.0.6/reference/html/index.html#embedded-objects
When I'm using
SpannerRepository.save(Entity)
, everything works as expected, but when I'm doingSpannerRepository.findById(Entity.id)
, I'm gettingSpannerDataException: Column not found
. The logs from GapicSpannerRpc look good, it seems that the problem is somewhere during mapping.I made a new sample project with Spring Initializr (Spring Boot 2.5.7, Gradle, Kotlin) and version 2.0.6 of spring-cloud-gcp-starter-data-spanner.
Here is the DDL I used to create a new table in Spanner:
Minimal example code:
Spanner trace:
Edit: added sample repository: https://github.com/mixefy/embedded-objects
The text was updated successfully, but these errors were encountered: