Class JdbcIdentityRepository
java.lang.Object
org.jwcarman.who.jdbc.JdbcIdentityRepository
- All Implemented Interfaces:
IdentityRepository
JDBC implementation of
IdentityRepository backed by the who_identity table.-
Constructor Summary
ConstructorsConstructorDescriptionJdbcIdentityRepository(org.springframework.jdbc.core.simple.JdbcClient jdbcClient) Creates the repository, which keeps identities in who's tables. -
Method Summary
Modifier and TypeMethodDescriptionbooleanchangeStatus(UUID id, IdentityStatus status) Sets the status of the identity with the given UUID, reporting whether anything changed.longCounts the identitiesIdentityRepository.findPage(Optional, Optional, Optional, int, int)pages through for the same filters.voiddeleteById(UUID id) Deletes the identity with the given UUID.booleanexistsById(UUID id) Returns whether an identity with the given UUID exists.Finds an identity by its UUID.findPage(Optional<IdentityStatus> status, Optional<UUID> roleId, Optional<Set<UUID>> ids, int page, int size) Returns one page of identities, oldest first: ordered by creation time, then by id.Finds an identity and locks its row until the surrounding transaction ends, so that concurrent callers serialize on it.Persists the given identity, inserting or updating as necessary.
-
Constructor Details
-
JdbcIdentityRepository
public JdbcIdentityRepository(org.springframework.jdbc.core.simple.JdbcClient jdbcClient) Creates the repository, which keeps identities in who's tables.- Parameters:
jdbcClient- the database
-
-
Method Details
-
findById
Description copied from interface:IdentityRepositoryFinds an identity by its UUID.- Specified by:
findByIdin interfaceIdentityRepository- Parameters:
id- the identity UUID- Returns:
- the identity, or empty if not found
-
lockById
Description copied from interface:IdentityRepositoryFinds an identity and locks its row until the surrounding transaction ends, so that concurrent callers serialize on it. Call it inside a transaction.- Specified by:
lockByIdin interfaceIdentityRepository- Parameters:
id- the identity UUID- Returns:
- the identity, or empty if not found
-
findPage
public List<Identity> findPage(Optional<IdentityStatus> status, Optional<UUID> roleId, Optional<Set<UUID>> ids, int page, int size) Description copied from interface:IdentityRepositoryReturns one page of identities, oldest first: ordered by creation time, then by id. Every filter given must match.- Specified by:
findPagein interfaceIdentityRepository- Parameters:
status- only identities with this status; empty for any statusroleId- only identities assigned this who-rbac role, matched in the query against who-rbac's role assignments, so a role's holders are never listed first; empty for any role. Give one only where who-rbac's schema is installedids- only identities among these ids; empty for any id. An empty set matches nonepage- the zero-based page number; must not be negativesize- the most identities on a page; must be positive- Returns:
- the identities on that page (never null; empty past the last page)
-
count
Description copied from interface:IdentityRepositoryCounts the identitiesIdentityRepository.findPage(Optional, Optional, Optional, int, int)pages through for the same filters.- Specified by:
countin interfaceIdentityRepository- Parameters:
status- only identities with this status; empty for any statusroleId- only identities assigned this who-rbac role; empty for any roleids- only identities among these ids; empty for any id. An empty set matches none- Returns:
- how many identities match
-
save
Description copied from interface:IdentityRepositoryPersists the given identity, inserting or updating as necessary.- Specified by:
savein interfaceIdentityRepository- Parameters:
identity- the identity to save- Returns:
- the saved identity
-
existsById
Description copied from interface:IdentityRepositoryReturns whether an identity with the given UUID exists.- Specified by:
existsByIdin interfaceIdentityRepository- Parameters:
id- the identity UUID- Returns:
- true if an identity exists with that UUID
-
deleteById
Description copied from interface:IdentityRepositoryDeletes the identity with the given UUID.- Specified by:
deleteByIdin interfaceIdentityRepository- Parameters:
id- the identity UUID
-
changeStatus
Description copied from interface:IdentityRepositorySets the status of the identity with the given UUID, reporting whether anything changed. The default finds then saves; implementations backed by a database should override it with one conditional update, so that concurrent callers cannot both see a change.- Specified by:
changeStatusin interfaceIdentityRepository- Parameters:
id- the identity UUIDstatus- the new status- Returns:
trueonly if the identity exists and its status was different
-