Skip to content
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

Add @Transient properties to PersistentEntity and use value defaulting for transient constructor properties #2985

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mp911de
Copy link
Member

@mp911de mp911de commented Nov 21, 2023

We now maintain @Transient metadata in the mapping model to determine whether a transient property has been used in a Kotlin Data class, Record or plain Java class.

record MyRecord(String firstname, @Transient String lastname) {
}
data class MyDataClass(@Transient val firstname: String = "foo", @Transient val age: Int)

Entity instantiation populates properties with default values (null for object types, or primitive default values) so that Kotlin data classes can use defaulting.

Closes #1432
Closes #2942

We now ignore transient properties used in constructors. Regular transient properties default to the Java default values (null for object types, 0 for numeric primitives and so on).

Using transient properties allows leveraging Kotlin's defaulting mechanism to infer default values.

Record components can also be annotated with the Transient annotation to allow record construction. While this can be useful, we recommend using the Value annotation to use SpEL expressions to determine a useful value.
Add missing Override annotations, consistently use literal tags for boolean values.
@mp911de mp911de added the type: enhancement A general enhancement label Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
1 participant