Class AbstractRepositoryOperations
- java.lang.Object
-
- io.micronaut.data.runtime.operations.internal.AbstractRepositoryOperations
-
- All Implemented Interfaces:
io.micronaut.context.ApplicationContextProvider
- Direct Known Subclasses:
AbstractSqlRepositoryOperations
,DefaultMongoRepositoryOperations
,DefaultReactiveMongoRepositoryOperations
@Internal public abstract class AbstractRepositoryOperations extends java.lang.Object implements io.micronaut.context.ApplicationContextProvider
Abstract repository implementation.- Since:
- 3.1.0
- Author:
- Denis Stepanov
-
-
Field Summary
Fields Modifier and Type Field Description protected AttributeConverterRegistry
attributeConverterRegistry
protected DataConversionService<?>
conversionService
protected DateTimeProvider
dateTimeProvider
protected EntityEventListener<java.lang.Object>
entityEventRegistry
protected io.micronaut.http.codec.MediaTypeCodec
jsonCodec
protected RuntimeEntityRegistry
runtimeEntityRegistry
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractRepositoryOperations(java.util.List<io.micronaut.http.codec.MediaTypeCodec> codecs, DateTimeProvider<java.lang.Object> dateTimeProvider, RuntimeEntityRegistry runtimeEntityRegistry, DataConversionService<?> conversionService, AttributeConverterRegistry attributeConverterRegistry)
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
checkOptimisticLocking(int expected, java.lang.Number received)
Compare the expected modifications and the received rows count.io.micronaut.context.ApplicationContext
getApplicationContext()
DataConversionService<?>
getConversionService()
<T> RuntimePersistentEntity<T>
getEntity(java.lang.Class<T> type)
protected RuntimePersistentProperty<java.lang.Object>
getIdReader(java.lang.Object o)
Obtain an ID reader for the given object.protected boolean
isOnlySingleEndedJoins(RuntimePersistentEntity<?> rootPersistentEntity, java.util.Set<JoinPath> joinFetchPaths)
Check if joined associated are all single ended (Can produce only one result).protected <T> T
triggerPostLoad(T entity, RuntimePersistentEntity<T> pe, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
Trigger the post load event.
-
-
-
Field Detail
-
jsonCodec
protected final io.micronaut.http.codec.MediaTypeCodec jsonCodec
-
entityEventRegistry
protected final EntityEventListener<java.lang.Object> entityEventRegistry
-
dateTimeProvider
protected final DateTimeProvider dateTimeProvider
-
runtimeEntityRegistry
protected final RuntimeEntityRegistry runtimeEntityRegistry
-
conversionService
protected final DataConversionService<?> conversionService
-
attributeConverterRegistry
protected final AttributeConverterRegistry attributeConverterRegistry
-
-
Constructor Detail
-
AbstractRepositoryOperations
protected AbstractRepositoryOperations(java.util.List<io.micronaut.http.codec.MediaTypeCodec> codecs, DateTimeProvider<java.lang.Object> dateTimeProvider, RuntimeEntityRegistry runtimeEntityRegistry, DataConversionService<?> conversionService, AttributeConverterRegistry attributeConverterRegistry)
Default constructor.- Parameters:
codecs
- The media type codecsdateTimeProvider
- The date time providerruntimeEntityRegistry
- The entity registryconversionService
- The conversion serviceattributeConverterRegistry
- The attribute converter registry
-
-
Method Detail
-
getConversionService
public DataConversionService<?> getConversionService()
- Returns:
- the conversion service
-
getApplicationContext
public io.micronaut.context.ApplicationContext getApplicationContext()
- Specified by:
getApplicationContext
in interfaceio.micronaut.context.ApplicationContextProvider
-
getEntity
@NonNull public final <T> RuntimePersistentEntity<T> getEntity(@NonNull java.lang.Class<T> type)
-
triggerPostLoad
protected <T> T triggerPostLoad(@NonNull T entity, RuntimePersistentEntity<T> pe, io.micronaut.core.annotation.AnnotationMetadata annotationMetadata)
Trigger the post load event.- Type Parameters:
T
- The generic type- Parameters:
entity
- The entitype
- The persistent entityannotationMetadata
- The annotation metadata- Returns:
- The entity, possibly modified
-
getIdReader
@NonNull protected final RuntimePersistentProperty<java.lang.Object> getIdReader(@NonNull java.lang.Object o)
Obtain an ID reader for the given object.- Parameters:
o
- The object- Returns:
- The ID reader
-
checkOptimisticLocking
protected void checkOptimisticLocking(int expected, java.lang.Number received)
Compare the expected modifications and the received rows count. If not equals throwOptimisticLockException
.- Parameters:
expected
- The expected valuereceived
- THe received value
-
isOnlySingleEndedJoins
protected boolean isOnlySingleEndedJoins(RuntimePersistentEntity<?> rootPersistentEntity, java.util.Set<JoinPath> joinFetchPaths)
Check if joined associated are all single ended (Can produce only one result).- Parameters:
rootPersistentEntity
- The root entityjoinFetchPaths
- The join paths- Returns:
- true if there are no "many" joins
-
-