Class LcReactiveDataRelationalClient
- java.lang.Object
-
- net.lecousin.reactive.data.relational.LcReactiveDataRelationalClient
-
@Component public class LcReactiveDataRelationalClient extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static org.apache.commons.logging.Loglogger
-
Constructor Summary
Constructors Constructor Description LcReactiveDataRelationalClient(org.springframework.r2dbc.core.DatabaseClient client, org.springframework.data.mapping.context.MappingContext<org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?>,? extends org.springframework.data.relational.core.mapping.RelationalPersistentProperty> mappingContext, RelationalDatabaseSchemaDialect schemaDialect, LcReactiveDataAccessStrategy dataAccess, LcMappingR2dbcConverter mapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RelationalDatabaseSchemabuildSchemaFromEntities()Build the schema definition from all known entities.RelationalDatabaseSchemabuildSchemaFromEntities(Collection<Class<?>> classes)Build the schema definition from given entities.reactor.core.publisher.Mono<Void>createSchemaContent(RelationalDatabaseSchema schema)Create tables, constraints and sequences from the given schema.<T> reactor.core.publisher.Mono<Void>delete(Iterable<T> entities)Delete the given entities (with cascade).<T> reactor.core.publisher.Mono<Void>delete(org.reactivestreams.Publisher<T> publisher)Delete the given entities (with cascade).<T> reactor.core.publisher.Mono<Void>delete(org.reactivestreams.Publisher<T> publisher, int bunchSize, Duration bunchTimeout)Delete the given entities (with cascade), by bunch.<T> reactor.core.publisher.Mono<Void>delete(T entity)Delete the given entity (with cascade).reactor.core.publisher.Mono<Void>dropCreateSchemaContent(RelationalDatabaseSchema schema)Drop then create the given schema.reactor.core.publisher.Mono<Void>dropSchemaContent(RelationalDatabaseSchema schema)Drop all elements from the given schema.<T> reactor.core.publisher.Flux<T>execute(SelectQuery<T> query, LcEntityReader reader)Execute a select query using the given LcEntityReader to map rows to entities.reactor.core.publisher.Mono<Long>executeCount(SelectQuery<?> query)Execute a select query.LcReactiveDataAccessStrategygetDataAccess()org.springframework.data.r2dbc.dialect.R2dbcDialectgetDialect()LcMappingR2dbcConvertergetMapper()org.springframework.data.mapping.context.MappingContext<org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?>,? extends org.springframework.data.relational.core.mapping.RelationalPersistentProperty>getMappingContext()RelationalDatabaseSchemaDialectgetSchemaDialect()org.springframework.r2dbc.core.DatabaseClientgetSpringClient()<T> reactor.core.publisher.Flux<T>lazyLoad(Iterable<T> entities, org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?> entityType)Load the given entities from database.<T> reactor.core.publisher.Mono<T>lazyLoad(T entity)Load the given entity from database.<T> reactor.core.publisher.Mono<T>lazyLoad(T entity, EntityState state, org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?> entityType)Load the given entity from database.<T> reactor.core.publisher.Mono<T>lazyLoad(T entity, org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?> entityType)Load the given entity from database.<T> reactor.core.publisher.Flux<T>save(Iterable<T> entities)Save the given entities (insert or update in cascade).<T> reactor.core.publisher.Flux<T>save(org.reactivestreams.Publisher<T> publisher)Save the given entities (insert or update in cascade).<T> reactor.core.publisher.Mono<T>save(T entity)Save the given entity (insert or update in cascade).reactor.core.publisher.Mono<Void>saveAll(Iterable<Object> entities)Save the given entities (insert or update in cascade).reactor.core.publisher.Mono<Void>saveAll(Object... entities)Save the given entities (insert or update in cascade).
-
-
-
Constructor Detail
-
LcReactiveDataRelationalClient
public LcReactiveDataRelationalClient(org.springframework.r2dbc.core.DatabaseClient client, org.springframework.data.mapping.context.MappingContext<org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?>,? extends org.springframework.data.relational.core.mapping.RelationalPersistentProperty> mappingContext, RelationalDatabaseSchemaDialect schemaDialect, LcReactiveDataAccessStrategy dataAccess, LcMappingR2dbcConverter mapper)
-
-
Method Detail
-
getSpringClient
public org.springframework.r2dbc.core.DatabaseClient getSpringClient()
- Returns:
- the Spring R2DBC database client.
-
getMapper
public LcMappingR2dbcConverter getMapper()
- Returns:
- entity mapper and converters.
-
getMappingContext
public org.springframework.data.mapping.context.MappingContext<org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?>,? extends org.springframework.data.relational.core.mapping.RelationalPersistentProperty> getMappingContext()
- Returns:
- the Spring Data mappign context containing all known entities.
-
getDataAccess
public LcReactiveDataAccessStrategy getDataAccess()
- Returns:
- the Spring Data R2DBC data access strategy.
-
getSchemaDialect
public RelationalDatabaseSchemaDialect getSchemaDialect()
- Returns:
- the extended dialect.
-
getDialect
public org.springframework.data.r2dbc.dialect.R2dbcDialect getDialect()
- Returns:
- the R2DBC native dialect.
-
dropSchemaContent
public reactor.core.publisher.Mono<Void> dropSchemaContent(RelationalDatabaseSchema schema)
Drop all elements from the given schema.
-
createSchemaContent
public reactor.core.publisher.Mono<Void> createSchemaContent(RelationalDatabaseSchema schema)
Create tables, constraints and sequences from the given schema.
-
dropCreateSchemaContent
public reactor.core.publisher.Mono<Void> dropCreateSchemaContent(RelationalDatabaseSchema schema)
Drop then create the given schema.
-
buildSchemaFromEntities
public RelationalDatabaseSchema buildSchemaFromEntities()
Build the schema definition from all known entities.
-
buildSchemaFromEntities
public RelationalDatabaseSchema buildSchemaFromEntities(Collection<Class<?>> classes)
Build the schema definition from given entities.
-
save
public <T> reactor.core.publisher.Mono<T> save(T entity)
Save the given entity (insert or update in cascade).
-
save
public <T> reactor.core.publisher.Flux<T> save(Iterable<T> entities)
Save the given entities (insert or update in cascade).
-
save
public <T> reactor.core.publisher.Flux<T> save(org.reactivestreams.Publisher<T> publisher)
Save the given entities (insert or update in cascade).
-
saveAll
public reactor.core.publisher.Mono<Void> saveAll(Iterable<Object> entities)
Save the given entities (insert or update in cascade).
-
saveAll
public reactor.core.publisher.Mono<Void> saveAll(Object... entities)
Save the given entities (insert or update in cascade).
-
lazyLoad
public <T> reactor.core.publisher.Mono<T> lazyLoad(T entity)
Load the given entity from database.
-
lazyLoad
public <T> reactor.core.publisher.Mono<T> lazyLoad(T entity, org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?> entityType)Load the given entity from database.
-
lazyLoad
public <T> reactor.core.publisher.Mono<T> lazyLoad(T entity, EntityState state, org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?> entityType)Load the given entity from database.
-
lazyLoad
public <T> reactor.core.publisher.Flux<T> lazyLoad(Iterable<T> entities, org.springframework.data.relational.core.mapping.RelationalPersistentEntity<?> entityType)
Load the given entities from database.
-
execute
public <T> reactor.core.publisher.Flux<T> execute(SelectQuery<T> query, @Nullable LcEntityReader reader)
Execute a select query using the given LcEntityReader to map rows to entities.
-
executeCount
public reactor.core.publisher.Mono<Long> executeCount(SelectQuery<?> query)
Execute a select query.
-
delete
public <T> reactor.core.publisher.Mono<Void> delete(T entity)
Delete the given entity (with cascade).
-
delete
public <T> reactor.core.publisher.Mono<Void> delete(Iterable<T> entities)
Delete the given entities (with cascade).
-
delete
public <T> reactor.core.publisher.Mono<Void> delete(org.reactivestreams.Publisher<T> publisher)
Delete the given entities (with cascade).
-
delete
public <T> reactor.core.publisher.Mono<Void> delete(org.reactivestreams.Publisher<T> publisher, int bunchSize, Duration bunchTimeout)
Delete the given entities (with cascade), by bunch.- Parameters:
publisher- entities to deletebunchSize- bufferize entities to delete them by bunchbunchTimeout- timeout after which a the current bunch of entities are deleted even the bunch is not full
-
-