Search in sources :

Example 1 with SessionFactoryFactoryBean

use of org.springframework.data.cassandra.config.SessionFactoryFactoryBean in project spring-data-cassandra by spring-projects.

the class CassandraConfig method sessionFactory.

@Bean
public SessionFactoryFactoryBean sessionFactory(CqlSession session, CassandraConverter converter) {
    SessionFactoryFactoryBean sessionFactory = new SessionFactoryFactoryBean();
    sessionFactory.setSession(session);
    sessionFactory.setConverter(converter);
    sessionFactory.setSchemaAction(SchemaAction.NONE);
    return sessionFactory;
}
Also used : SessionFactoryFactoryBean(org.springframework.data.cassandra.config.SessionFactoryFactoryBean) Bean(org.springframework.context.annotation.Bean) SessionFactoryFactoryBean(org.springframework.data.cassandra.config.SessionFactoryFactoryBean) CqlSessionFactoryBean(org.springframework.data.cassandra.config.CqlSessionFactoryBean)

Example 2 with SessionFactoryFactoryBean

use of org.springframework.data.cassandra.config.SessionFactoryFactoryBean in project spring-boot by spring-projects.

the class CassandraDataAutoConfiguration method cassandraSessionFactory.

@Bean
@ConditionalOnMissingBean(SessionFactory.class)
public SessionFactoryFactoryBean cassandraSessionFactory(Environment environment, CassandraConverter converter) {
    SessionFactoryFactoryBean session = new SessionFactoryFactoryBean();
    session.setSession(this.session);
    session.setConverter(converter);
    Binder binder = Binder.get(environment);
    binder.bind("spring.data.cassandra.schema-action", SchemaAction.class).ifBound(session::setSchemaAction);
    return session;
}
Also used : Binder(org.springframework.boot.context.properties.bind.Binder) SessionFactoryFactoryBean(org.springframework.data.cassandra.config.SessionFactoryFactoryBean) SchemaAction(org.springframework.data.cassandra.config.SchemaAction) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean) SessionFactoryFactoryBean(org.springframework.data.cassandra.config.SessionFactoryFactoryBean)

Aggregations

Bean (org.springframework.context.annotation.Bean)2 SessionFactoryFactoryBean (org.springframework.data.cassandra.config.SessionFactoryFactoryBean)2 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Binder (org.springframework.boot.context.properties.bind.Binder)1 CqlSessionFactoryBean (org.springframework.data.cassandra.config.CqlSessionFactoryBean)1 SchemaAction (org.springframework.data.cassandra.config.SchemaAction)1