Class JpaMapKeycloakTransaction<RE extends JpaRootEntity,E extends AbstractEntity,M>
- java.lang.Object
-
- org.keycloak.models.map.storage.jpa.JpaMapKeycloakTransaction<RE,E,M>
-
- All Implemented Interfaces:
KeycloakTransaction
,MapKeycloakTransaction<E,M>
- Direct Known Subclasses:
JpaClientMapKeycloakTransaction
,JpaClientScopeMapKeycloakTransaction
,JpaGroupMapKeycloakTransaction
,JpaRealmMapKeycloakTransaction
,JpaRoleMapKeycloakTransaction
,JpaRootAuthenticationSessionMapKeycloakTransaction
public abstract class JpaMapKeycloakTransaction<RE extends JpaRootEntity,E extends AbstractEntity,M> extends Object implements MapKeycloakTransaction<E,M>
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.persistence.EntityManager
em
-
Constructor Summary
Constructors Constructor Description JpaMapKeycloakTransaction(Class<RE> entityType, javax.persistence.EntityManager em)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
begin()
void
commit()
E
create(E mapEntity)
Instructs this transaction to add a new value into the underlying store on commit.protected abstract JpaModelCriteriaBuilder
createJpaModelCriteriaBuilder()
boolean
delete(String key)
Instructs this transaction to delete a value associated with the identifierkey
from the underlying store on commit.long
delete(QueryParameters<M> queryParameters)
Instructs this transaction to remove values (identified bymcb
filter) from the underlying store on commit.long
getCount(QueryParameters<M> queryParameters)
Returns a number of values present in the underlying storage that fulfill the given criteria with respect to changes done in the current transaction.boolean
getRollbackOnly()
boolean
isActive()
protected abstract E
mapToEntityDelegate(RE original)
E
read(String key)
Provides possibility to lookup for values by akey
in the underlying store with respect to changes done in current transaction.Stream<E>
read(QueryParameters<M> queryParameters)
Returns a stream of values from underlying storage that are updated based on the current transaction changes; i.e.void
rollback()
protected abstract javax.persistence.criteria.Selection<? extends RE>
selectCbConstruct(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.Root<RE> root)
protected abstract void
setEntityVersion(JpaRootEntity entity)
void
setRollbackOnly()
-
-
-
Method Detail
-
selectCbConstruct
protected abstract javax.persistence.criteria.Selection<? extends RE> selectCbConstruct(javax.persistence.criteria.CriteriaBuilder cb, javax.persistence.criteria.Root<RE> root)
-
setEntityVersion
protected abstract void setEntityVersion(JpaRootEntity entity)
-
createJpaModelCriteriaBuilder
protected abstract JpaModelCriteriaBuilder createJpaModelCriteriaBuilder()
-
create
public E create(E mapEntity)
Description copied from interface:MapKeycloakTransaction
Instructs this transaction to add a new value into the underlying store on commit.Updates to the returned instances of
V
would be visible in the current transaction and will propagate into the underlying store upon commit. The ID of the entity passed in the parameter might change to a different value in the returned value if the underlying storage decided this was necessary. If the ID of the entity was null before, it will be set on the returned value.- Specified by:
create
in interfaceMapKeycloakTransaction<RE extends JpaRootEntity,E extends AbstractEntity>
- Parameters:
mapEntity
- the value- Returns:
- Entity representing the
value
in the store. It may or may not be the same instance asvalue
.
-
read
public E read(String key)
Description copied from interface:MapKeycloakTransaction
Provides possibility to lookup for values by akey
in the underlying store with respect to changes done in current transaction. Updates to the returned instance would be visible in the current transaction and will propagate into the underlying store upon commit.- Specified by:
read
in interfaceMapKeycloakTransaction<RE extends JpaRootEntity,E extends AbstractEntity>
- Parameters:
key
- identifier of a value- Returns:
- a value associated with the given
key
-
read
public Stream<E> read(QueryParameters<M> queryParameters)
Description copied from interface:MapKeycloakTransaction
Returns a stream of values from underlying storage that are updated based on the current transaction changes; i.e. the result contains updates and excludes of records that have been created, updated or deleted in this transaction by methodsMapKeycloakTransaction.create(V)
,MapKeycloakTransaction.create(V)
,MapKeycloakTransaction.delete(java.lang.String)
, etc.Updates to the returned instances of
V
would be visible in the current transaction and will propagate into the underlying store upon commit.- Specified by:
read
in interfaceMapKeycloakTransaction<RE extends JpaRootEntity,E extends AbstractEntity>
- Parameters:
queryParameters
- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- values that fulfill the given criteria, that are updated based on changes in the current transaction
-
getCount
public long getCount(QueryParameters<M> queryParameters)
Description copied from interface:MapKeycloakTransaction
Returns a number of values present in the underlying storage that fulfill the given criteria with respect to changes done in the current transaction.- Specified by:
getCount
in interfaceMapKeycloakTransaction<RE extends JpaRootEntity,E extends AbstractEntity>
- Parameters:
queryParameters
- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- number of values present in the storage that fulfill the given criteria
-
delete
public boolean delete(String key)
Description copied from interface:MapKeycloakTransaction
Instructs this transaction to delete a value associated with the identifierkey
from the underlying store on commit.- Specified by:
delete
in interfaceMapKeycloakTransaction<RE extends JpaRootEntity,E extends AbstractEntity>
- Parameters:
key
- identifier of a value- Returns:
- Returns
true
if the object has been deleted or result cannot be determined,false
otherwise.
-
delete
public long delete(QueryParameters<M> queryParameters)
Description copied from interface:MapKeycloakTransaction
Instructs this transaction to remove values (identified bymcb
filter) from the underlying store on commit.- Specified by:
delete
in interfaceMapKeycloakTransaction<RE extends JpaRootEntity,E extends AbstractEntity>
- Parameters:
queryParameters
- parameters for the query like firstResult, maxResult, requested ordering, etc.- Returns:
- number of removed objects (might return
-1
if not supported)
-
begin
public void begin()
- Specified by:
begin
in interfaceKeycloakTransaction
-
commit
public void commit()
- Specified by:
commit
in interfaceKeycloakTransaction
-
rollback
public void rollback()
- Specified by:
rollback
in interfaceKeycloakTransaction
-
setRollbackOnly
public void setRollbackOnly()
- Specified by:
setRollbackOnly
in interfaceKeycloakTransaction
-
getRollbackOnly
public boolean getRollbackOnly()
- Specified by:
getRollbackOnly
in interfaceKeycloakTransaction
-
isActive
public boolean isActive()
- Specified by:
isActive
in interfaceKeycloakTransaction
-
-