Search in sources :

Example 1 with DefaultSessionFactory

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));
}
Also used : DefaultSessionFactory(org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory)

Example 2 with DefaultSessionFactory

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);
}
Also used : MapSessionFactoryLookup(org.springframework.data.cassandra.core.cql.session.lookup.MapSessionFactoryLookup) DefaultSessionFactory(org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory) Test(org.junit.jupiter.api.Test)

Example 3 with DefaultSessionFactory

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));
}
Also used : DefaultSessionFactory(org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with DefaultSessionFactory

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);
}
Also used : MapSessionFactoryLookup(org.springframework.data.cassandra.core.cql.session.lookup.MapSessionFactoryLookup) DefaultSessionFactory(org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory) Test(org.junit.jupiter.api.Test)

Example 5 with DefaultSessionFactory

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));
}
Also used : DefaultSessionFactory(org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory)

Aggregations

DefaultSessionFactory (org.springframework.data.cassandra.core.cql.session.DefaultSessionFactory)6 Test (org.junit.jupiter.api.Test)2 MapSessionFactoryLookup (org.springframework.data.cassandra.core.cql.session.lookup.MapSessionFactoryLookup)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1