Auto-configure CqlTemplate and ReactiveCqlTemplate
See gh-44291 Signed-off-by: Dmytro Nosan <dimanosan@gmail.com>
This commit is contained in:
parent
e884aa33fe
commit
e8661f6bee
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -45,6 +45,8 @@ import org.springframework.data.cassandra.core.CassandraTemplate;
|
|||
import org.springframework.data.cassandra.core.convert.CassandraConverter;
|
||||
import org.springframework.data.cassandra.core.convert.CassandraCustomConversions;
|
||||
import org.springframework.data.cassandra.core.convert.MappingCassandraConverter;
|
||||
import org.springframework.data.cassandra.core.cql.CqlOperations;
|
||||
import org.springframework.data.cassandra.core.cql.CqlTemplate;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
||||
import org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver;
|
||||
|
||||
|
|
@ -120,6 +122,12 @@ public class CassandraDataAutoConfiguration {
|
|||
return new CassandraTemplate(sessionFactory, converter);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(CqlOperations.class)
|
||||
public CqlTemplate cqlTemplate(SessionFactory sessionFactory) {
|
||||
return new CqlTemplate(sessionFactory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public CassandraCustomConversions cassandraCustomConversions() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -30,6 +30,8 @@ import org.springframework.data.cassandra.ReactiveSessionFactory;
|
|||
import org.springframework.data.cassandra.core.ReactiveCassandraOperations;
|
||||
import org.springframework.data.cassandra.core.ReactiveCassandraTemplate;
|
||||
import org.springframework.data.cassandra.core.convert.CassandraConverter;
|
||||
import org.springframework.data.cassandra.core.cql.ReactiveCqlOperations;
|
||||
import org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate;
|
||||
import org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiveSession;
|
||||
import org.springframework.data.cassandra.core.cql.session.DefaultReactiveSessionFactory;
|
||||
|
||||
|
|
@ -65,4 +67,10 @@ public class CassandraReactiveDataAutoConfiguration {
|
|||
return new ReactiveCassandraTemplate(reactiveCassandraSession, converter);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(ReactiveCqlOperations.class)
|
||||
public ReactiveCqlTemplate reactiveCqlTemplate(ReactiveSessionFactory reactiveCassandraSessionFactory) {
|
||||
return new ReactiveCqlTemplate(reactiveCassandraSessionFactory);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -33,6 +33,7 @@ import org.springframework.core.convert.converter.Converter;
|
|||
import org.springframework.data.cassandra.core.CassandraTemplate;
|
||||
import org.springframework.data.cassandra.core.convert.CassandraConverter;
|
||||
import org.springframework.data.cassandra.core.convert.CassandraCustomConversions;
|
||||
import org.springframework.data.cassandra.core.cql.CqlTemplate;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
||||
import org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver;
|
||||
import org.springframework.data.domain.ManagedTypes;
|
||||
|
|
@ -65,6 +66,12 @@ class CassandraDataAutoConfigurationTests {
|
|||
assertThat(this.context.getBeanNamesForType(CassandraTemplate.class)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void cqlTemplateExists() {
|
||||
load(CassandraMockConfiguration.class);
|
||||
assertThat(this.context.getBeanNamesForType(CqlTemplate.class)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void entityScanShouldSetManagedTypes() {
|
||||
load(EntityScanConfig.class);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -27,6 +27,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.cassandra.core.ReactiveCassandraTemplate;
|
||||
import org.springframework.data.cassandra.core.convert.CassandraConverter;
|
||||
import org.springframework.data.cassandra.core.cql.ReactiveCqlTemplate;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
||||
import org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver;
|
||||
import org.springframework.data.domain.ManagedTypes;
|
||||
|
|
@ -58,6 +59,12 @@ class CassandraReactiveDataAutoConfigurationTests {
|
|||
assertThat(this.context.getBeanNamesForType(ReactiveCassandraTemplate.class)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void reactiveCqlTemplateExists() {
|
||||
load("spring.cassandra.keyspaceName:boot_test");
|
||||
assertThat(this.context.getBeanNamesForType(ReactiveCqlTemplate.class)).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void entityScanShouldSetManagedTypes() {
|
||||
load(EntityScanConfig.class, "spring.cassandra.keyspaceName:boot_test");
|
||||
|
|
|
|||
Loading…
Reference in New Issue