use of org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory in project spring-data-cassandra by spring-projects.
the class CassandraCqlTemplateFactoryBean method setSession.
/**
* Sets the Cassandra {@link CqlSession} to use. The {@link CqlTemplate} will use the logged keyspace of the
* underlying {@link CqlSession}. Don't change the keyspace using CQL but use multiple {@link CqlSession} and
* {@link CqlTemplate} beans.
*
* @param session must not be {@literal null}.
*/
public void setSession(CqlSession session) {
Assert.notNull(session, "Session must not be null");
setSessionFactory(new DefaultSessionFactory(session));
}
use of org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory in project spring-data-cassandra by spring-projects.
the class AbstractRoutingSessionFactoryUnitTests method shouldAllowModificationsAfterInitialization.
// DATACASS-330
@Test
void shouldAllowModificationsAfterInitialization() {
MapSessionFactoryLookup lookup = new MapSessionFactoryLookup();
sut.setSessionFactoryLookup(lookup);
sut.setTargetSessionFactories((Map) lookup.getSessionFactories());
sut.afterPropertiesSet();
sut.setLookupKey("lookup-key");
assertThat(sut.getSession()).isSameAs(defaultSession);
lookup.addSessionFactory("lookup-key", new DefaultSessionFactory(routedSession));
sut.afterPropertiesSet();
assertThat(sut.getSession()).isSameAs(routedSession);
}
use of org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory in project spring-data-cassandra by spring-projects.
the class AbstractRoutingSessionFactoryUnitTests method before.
@BeforeEach
void before() throws Exception {
sut = new StubbedRoutingSessionFactory();
sut.setDefaultTargetSessionFactory(new DefaultSessionFactory(defaultSession));
}
use of org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory in project spring-data-cassandra by spring-projects.
the class AbstractRoutingSessionFactoryUnitTests method shouldLookupFromMap.
// DATACASS-330
@Test
void shouldLookupFromMap() {
MapSessionFactoryLookup lookup = new MapSessionFactoryLookup("lookup-key", new DefaultSessionFactory(routedSession));
sut.setSessionFactoryLookup(lookup);
sut.setTargetSessionFactories(Collections.singletonMap("my-key", "lookup-key"));
sut.afterPropertiesSet();
sut.setLookupKey("my-key");
assertThat(sut.getSession()).isSameAs(routedSession);
}
use of org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory in project spring-data-cassandra by spring-projects.
the class CassandraTemplateFactoryBean method setSession.
/**
* Sets the Cassandra {@link CqlSession} to use. The {@link CassandraTemplate} will use the logged keyspace of the
* underlying {@link CqlSession}. Don't change the keyspace using CQL but use a {@link SessionFactory}.
*
* @param session must not be {@literal null}.
*/
public void setSession(CqlSession session) {
Assert.notNull(session, "Session must not be null");
setSessionFactory(new DefaultSessionFactory(session));
}
Aggregations