-
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
Document restriction on embedded objects #784
Document restriction on embedded objects #784
Conversation
docs/src/main/asciidoc/spanner.adoc
Outdated
|
||
- embedded properties' column names must all be unique. | ||
- embedded properties must be mutable; otherwise you'll get an error, such as `SpannerDataException: Column not found: parent`. | ||
Therefore, you cannot use Kotlin's data class, which is immutable, to hold an embedded property. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not accurate. Kotlin's data class can have mutable field with 'var'. But the following definition (@Embedded var entityHistory
) failed too with the same error message as #774 (comment):
@Table(name = "Requests")
data class Request(
@PrimaryKey val requestId: String,
val payload: String,
@Embedded var entityHistory: EntityHistory? = null
)
What's the better description?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rephrase somehow that the constructor should not contain embedded properties?
It seems that to use Kotlin data class with @Embedded
, we can do something like:
@Table(name = "Requests")
data class Request(
@PrimaryKey val requestId: String,
val payload: String,
) {
@Embedded lateinit var entityHistory: EntityHistory
}
or
@Table(name = "Requests")
data class Request(
@PrimaryKey val requestId: String,
val payload: String,
) {
@Embedded var entityHistory: EntityHistory? = null
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "Embedded properties must not be passed through constructor"? This would apply to both Java and Kotlin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elefeint PTAL. Feel free to edit/merge this PR.
docs/src/main/asciidoc/spanner.adoc
Outdated
|
||
- embedded properties' column names must all be unique. | ||
- embedded properties must be mutable; otherwise you'll get an error, such as `SpannerDataException: Column not found: parent`. | ||
Therefore, you cannot use Kotlin's data class, which is immutable, to hold an embedded property. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Elena Felder <41136058+elefeint@users.noreply.github.com>
Kudos, SonarCloud Quality Gate passed! |
* restriction on embedded objects * Enhanced restriction on embedded properties * Update docs/src/main/asciidoc/spanner.adoc Co-authored-by: Elena Felder <41136058+elefeint@users.noreply.github.com> Co-authored-by: Elena Felder <41136058+elefeint@users.noreply.github.com>
Related to #774