Class JpaCustomizedUserRepository<D extends JpaUser>
java.lang.Object
com.broadleafcommerce.auth.user.provider.jpa.repository.JpaCustomizedUserRepository<D>
- All Implemented Interfaces:
CustomizedUserRepository<D>
,com.broadleafcommerce.common.extension.DomainTypeAware
public class JpaCustomizedUserRepository<D extends JpaUser>
extends Object
implements CustomizedUserRepository<D>
- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.persistence.criteria.Predicate
buildIdFilter
(String entityId, jakarta.persistence.criteria.Root<D> userEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected UserRepository<D>
replaceOnlyIfLastUpdatedBefore
(@NonNull String entityId, D user, @NonNull Instant lastUpdated) A specialized replace operation that does not invoke the "save" create-or-update behavior.void
setRepository
(UserRepository<D> repository)
-
Constructor Details
-
JpaCustomizedUserRepository
public JpaCustomizedUserRepository()
-
-
Method Details
-
setRepository
-
getDomainType
- Specified by:
getDomainType
in interfacecom.broadleafcommerce.common.extension.DomainTypeAware
-
replaceOnlyIfLastUpdatedBefore
@Nullable @Transactional public D replaceOnlyIfLastUpdatedBefore(@NonNull @NonNull String entityId, @NonNull D user, @NonNull @NonNull Instant lastUpdated) Description copied from interface:CustomizedUserRepository
A specialized replace operation that does not invoke the "save" create-or-update behavior. This operation should directly attempt an atomic update that the data store will reject if the entity is not found or has a lastUpdated ahead of the current change.This is intended to be used in concurrent scenarios where only one operation should succeed.
Note that this update should succeed even if the existing record is
User.archived
.Note that this method should also set the provided
User.archived
value, even if it istrue
.- Specified by:
replaceOnlyIfLastUpdatedBefore
in interfaceCustomizedUserRepository<D extends JpaUser>
- Parameters:
entityId
- the id of the entity to replaceuser
- the replacement entitylastUpdated
- the timestamp of the current change. This will be compared to the lastUpdated on the existing entity for determination of whether the replacement should occur. Furthermore, the replacement will have itsUser.lastUpdated
set to this value.- Returns:
- the user after replacement if successfully replaced, or
null
if the entity was not found or could not be updated due to its lastUpdated value.
-
buildIdFilter
-
getUserRepository
-