Class JmixDataRepositoryImpl<T,ID>
java.lang.Object
io.jmix.core.impl.repository.support.JmixDataRepositoryImpl<T,ID>
- Type Parameters:
T
-ID
-
- All Implemented Interfaces:
JmixDataRepository<T,
,ID> org.springframework.data.repository.CrudRepository<T,
,ID> org.springframework.data.repository.PagingAndSortingRepository<T,
,ID> org.springframework.data.repository.Repository<T,
ID>
@NoRepositoryBean
public class JmixDataRepositoryImpl<T,ID>
extends Object
implements JmixDataRepository<T,ID>, org.springframework.data.repository.CrudRepository<T,ID>
Implementation of base repository methods used by application repository beans.
-
Field Summary
Modifier and TypeFieldDescriptionprotected DataManager
protected Metadata
protected CrudMethodMetadata.Accessor
protected UnconstrainedDataManager
-
Constructor Summary
ConstructorDescriptionJmixDataRepositoryImpl
(Class<T> domainClass, DataManager dataManager, Metadata metadata, CrudMethodMetadata.Accessor methodMetadataAccessor) -
Method Summary
Modifier and TypeMethodDescriptionprotected FluentLoader.ByCondition<T>
protected FluentLoader.ByCondition<T>
conditionOrAllLoader
(Condition condition) long
count()
long
count
(JmixDataRepositoryContext jmixContext) Returns the number of entities satisfyingcontext
available.create()
Instantiate an entity.void
void
void
void
deleteAllById
(Iterable<? extends ID> ids) void
deleteById
(ID id) protected void
deleteInternal
(Object... entities) boolean
existsById
(ID id) findAll()
Returns all instances of the typeT
loaded according tofetchPlan
findAll
(JmixDataRepositoryContext context) Returns all instances of the typeT
loaded bycontext
Returns all instances of the typeT
with the given IDs loaded according tofetchPlan
org.springframework.data.domain.Page<T>
findAll
(org.springframework.data.domain.Pageable pageable) org.springframework.data.domain.Page<T>
Returns aPage
of entities meeting the paging restriction provided in thePageable
object.org.springframework.data.domain.Page<T>
findAll
(org.springframework.data.domain.Pageable pageable, JmixDataRepositoryContext jmixContext) Returns aPage
of entities meeting the paging restriction provided in thePageable
object.findAll
(org.springframework.data.domain.Sort sort) Returns all entities sorted by the given options and loaded by specified FetchPlan.findAllById
(Iterable<ID> ids) Loads an entity by itsid
according tofetchPlan
Loads an entity by itsid
Loads an entity by itsid
according tofetchPlan
protected Map<String,
Serializable> getHints()
protected UnconstrainedDataManager
protected FluentLoader.ById<T>
<S extends T>
Ssave
(S entity) <S extends T>
SSaves theentity
and returns saved instance loaded with specifiedfetchPlan
.void
setDomainClass
(Class<T> domainClass) protected Collection<ID>
toCollection
(Iterable<ID> ids)
-
Field Details
-
metadata
-
unconstrainedDataManager
-
dataManager
-
methodMetadataAccessor
-
-
Constructor Details
-
JmixDataRepositoryImpl
public JmixDataRepositoryImpl(Class<T> domainClass, DataManager dataManager, Metadata metadata, CrudMethodMetadata.Accessor methodMetadataAccessor)
-
-
Method Details
-
create
Description copied from interface:JmixDataRepository
Instantiate an entity. InvokesMetadata.create(Class)
- Specified by:
create
in interfaceJmixDataRepository<T,
ID> - Returns:
- new instance of
<T>
.
-
findById
Description copied from interface:JmixDataRepository
Loads an entity by itsid
according tofetchPlan
- Specified by:
findById
in interfaceJmixDataRepository<T,
ID> - Parameters:
id
- must not be null.- Returns:
- the entity with the given id or Optional#empty() if none found.
-
getById
Description copied from interface:JmixDataRepository
Loads an entity by itsid
according tofetchPlan
- Specified by:
getById
in interfaceJmixDataRepository<T,
ID> - Parameters:
id
- must not be null.- Returns:
- the entity with the given id
-
getById
Description copied from interface:JmixDataRepository
Loads an entity by itsid
- Specified by:
getById
in interfaceJmixDataRepository<T,
ID> - Parameters:
id
- must not be null.- Returns:
- the entity with the given id
-
findAll
Description copied from interface:JmixDataRepository
Returns all instances of the typeT
loaded according tofetchPlan
- Specified by:
findAll
in interfaceJmixDataRepository<T,
ID> - Returns:
- all entities
-
findAll
Description copied from interface:JmixDataRepository
Returns all instances of the typeT
loaded bycontext
- Specified by:
findAll
in interfaceJmixDataRepository<T,
ID> - Returns:
- entities by context
- See Also:
-
findAll
Description copied from interface:JmixDataRepository
Returns all instances of the typeT
with the given IDs loaded according tofetchPlan
If some or all ids are not found, no entities are returned for these IDs.
- Specified by:
findAll
in interfaceJmixDataRepository<T,
ID> - Parameters:
ids
- must not be null nor contain any null values.fetchPlan
- defines entity graph to load.FetchPlan.BASE
will be used instead in case of null.- Returns:
- guaranteed to be not null. The size can be equal or less than the number of given ids.
-
save
-
saveAll
-
findById
-
existsById
-
findAll
-
findAllById
-
count
public long count() -
deleteById
-
delete
-
deleteAll
-
deleteAllById
-
deleteAll
public void deleteAll() -
deleteInternal
-
getDomainClass
-
setDomainClass
-
findAll
-
findAll
public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable) -
findAll
public Iterable<T> findAll(org.springframework.data.domain.Sort sort, @Nullable FetchPlan fetchPlan) Description copied from interface:JmixDataRepository
Returns all entities sorted by the given options and loaded by specified FetchPlan.- Specified by:
findAll
in interfaceJmixDataRepository<T,
ID> fetchPlan
- to load entity.FetchPlan.BASE
will be used iffetchPlan == null
- Returns:
- all entities sorted by the given options
-
findAll
public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable, @Nullable FetchPlan fetchPlan) Description copied from interface:JmixDataRepository
Returns aPage
of entities meeting the paging restriction provided in thePageable
object. Entities will be loaded according to passedfetchPlan
- Specified by:
findAll
in interfaceJmixDataRepository<T,
ID> fetchPlan
- to load entities.FetchPlan.BASE
will be used iffetchPlan == null
- Returns:
- a page of entities
-
findAll
public org.springframework.data.domain.Page<T> findAll(org.springframework.data.domain.Pageable pageable, JmixDataRepositoryContext jmixContext) Description copied from interface:JmixDataRepository
Returns aPage
of entities meeting the paging restriction provided in thePageable
object. Entities will be loaded according to passedparams
- Specified by:
findAll
in interfaceJmixDataRepository<T,
ID> jmixContext
-JmixDataRepositoryContext
to load entities.- Returns:
- a page of entities
-
count
Description copied from interface:JmixDataRepository
Returns the number of entities satisfyingcontext
available.- Specified by:
count
in interfaceJmixDataRepository<T,
ID> - Returns:
- the number of entities satisfying
context
.
-
save
Description copied from interface:JmixDataRepository
Saves theentity
and returns saved instance loaded with specifiedfetchPlan
.- Specified by:
save
in interfaceJmixDataRepository<T,
ID> - Parameters:
entity
- entity to save. Must not be nullfetchPlan
-FetchPlan
to reload saved entity with. Must be applicable toentity
-
getSuitableDataManager
-
getDataManager
- Specified by:
getDataManager
in interfaceJmixDataRepository<T,
ID> - Returns:
DataManager
to use in default methods.
-
getHints
-
conditionOrAllLoader
-
allLoader
-
idLoader
-
toCollection
-