Annotation Type PropertyStrategy
-
@Target(TYPE) @Retention(RUNTIME) public @interface PropertyStrategy
Annotates anEntityto customize certain aspects of the introspection process that determines which methods are considered as properties, and how new instances will be created.Example:
@Entity @PropertyStrategy(getterStyle = FLUENT) public class Account { ... }This annotation can be inherited from an interface or parent class.When neither the entity class nor any of its parent is explicitly annotated, the mapper will assume context-dependent defaults:
- for a Scala case class:
mutable = falseandgetterStyle = FLUENT. The mapper detects this case by checking if the entity implementsscala.Product. - for a Kotlin data class:
mutable = falseandgetterStyle = JAVABEANS. The mapper detects this case by checking if the entity is annotated withkotlin.Metadata, and if it has any method namedcomponent1(both of these are added automatically by the Kotlin compiler). - Java records (JDK 14 and above):
mutable = falseandgetterStyle = FLUENT. The mapper detects this case by checking if the entity extendsjava.lang.Record. - any other case:
mutable = true,getterStyle = JAVABEANSandsetterStyle = JAVABEANS.
@PropertyStrategy(getterStyle = FLUENT), it will be mutable). - for a Scala case class:
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description GetterStylegetterStyleThe style of getter.booleanmutableWhether the entity is mutable.SetterStylesetterStyleThe style of setter.
-
-
-
Element Detail
-
getterStyle
GetterStyle getterStyle
The style of getter. SeeGetterStyleand its constants for more explanations.- Default:
- com.datastax.oss.driver.api.mapper.entity.naming.GetterStyle.JAVABEANS
-
-
-
setterStyle
SetterStyle setterStyle
The style of setter. SeeSetterStyleand its constants for more explanations.This has no effect if
mutable()is false.- Default:
- com.datastax.oss.driver.api.mapper.entity.naming.SetterStyle.JAVABEANS
-
-