Class RelationalEntityVersionUtils
java.lang.Object
org.springframework.data.relational.core.conversion.RelationalEntityVersionUtils
Utilities commonly used to set/get properties for instances of RelationalPersistentEntities.
- Since:
- 2.0
- Author:
- Tyler Van Gorder
-
Method Summary
Modifier and TypeMethodDescriptionstatic <S> Number
getVersionNumberFromEntity
(S instance, RelationalPersistentEntity<S> persistentEntity, RelationalConverter converter) Get the current value of the version property for an instance of a relational persistent entity.static <S> S
setVersionNumberOnEntity
(S instance, Number version, RelationalPersistentEntity<S> persistentEntity, RelationalConverter converter) Set the version property on an instance of a relational persistent entity.
-
Method Details
-
getVersionNumberFromEntity
@Nullable public static <S> Number getVersionNumberFromEntity(S instance, RelationalPersistentEntity<S> persistentEntity, RelationalConverter converter) Get the current value of the version property for an instance of a relational persistent entity.- Parameters:
instance
- must not be null.persistentEntity
- must not be null.converter
- must not be null.- Returns:
- Current value of the version property
- Throws:
IllegalArgumentException
- if the entity does not have a version property.
-
setVersionNumberOnEntity
public static <S> S setVersionNumberOnEntity(S instance, @Nullable Number version, RelationalPersistentEntity<S> persistentEntity, RelationalConverter converter) Set the version property on an instance of a relational persistent entity. This method returns an instance of the same type with the updated version property and will correctly handle the case where the version is immutable.- Parameters:
instance
- must not be null.version
- The value to be set on the version property.persistentEntity
- must not be null.converter
- must not be null.- Returns:
- An instance of the entity with an updated version property.
- Throws:
IllegalArgumentException
- if the entity does not have a version property.
-