use of org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver in project spring-data-cassandra by spring-projects.
the class CassandraTemplate method newConverter.
private static MappingCassandraConverter newConverter(CqlSession session) {
MappingCassandraConverter converter = new MappingCassandraConverter();
converter.setUserTypeResolver(new SimpleUserTypeResolver(session));
converter.setCodecRegistry(session.getContext().getCodecRegistry());
converter.afterPropertiesSet();
return converter;
}
use of org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver in project spring-data-cassandra by spring-projects.
the class AbstractCassandraConfiguration method cassandraConverter.
/**
* Creates a {@link CassandraConverter} using the configured {@link #cassandraMapping()}.
*
* Will apply all specified {@link #customConversions()}.
*
* @return {@link CassandraConverter} used to convert Java and Cassandra value types during the mapping process.
* @see #cassandraMapping()
* @see #customConversions()
*/
@Bean
public CassandraConverter cassandraConverter() {
CqlSession cqlSession = getRequiredSession();
UserTypeResolver userTypeResolver = new SimpleUserTypeResolver(cqlSession, CqlIdentifier.fromCql(getKeyspaceName()));
MappingCassandraConverter converter = new MappingCassandraConverter(requireBeanOfType(CassandraMappingContext.class));
converter.setCodecRegistry(cqlSession.getContext().getCodecRegistry());
converter.setUserTypeResolver(userTypeResolver);
converter.setCustomConversions(requireBeanOfType(CassandraCustomConversions.class));
return converter;
}
use of org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver in project spring-data-cassandra by spring-projects.
the class CassandraTemplateIntegrationTests method setUp.
@BeforeEach
void setUp() {
MappingCassandraConverter converter = new MappingCassandraConverter();
converter.setUserTypeResolver(new SimpleUserTypeResolver(session, CqlIdentifier.fromCql(keyspace)));
converter.afterPropertiesSet();
cassandraVersion = CassandraVersion.get(session);
template = new CassandraTemplate(new CqlTemplate(session), converter);
prepareTemplate(template);
SchemaTestUtils.potentiallyCreateTableFor(User.class, template);
SchemaTestUtils.potentiallyCreateTableFor(UserToken.class, template);
SchemaTestUtils.potentiallyCreateTableFor(BookReference.class, template);
SchemaTestUtils.potentiallyCreateTableFor(TimeClass.class, template);
SchemaTestUtils.potentiallyCreateTableFor(TypeWithCompositeKey.class, template);
SchemaTestUtils.potentiallyCreateTableFor(WithNullableEmbeddedType.class, template);
SchemaTestUtils.potentiallyCreateTableFor(WithEmptyEmbeddedType.class, template);
SchemaTestUtils.potentiallyCreateTableFor(WithPrefixedNullableEmbeddedType.class, template);
SchemaTestUtils.createTableAndTypes(OuterWithNullableEmbeddedType.class, template);
SchemaTestUtils.createTableAndTypes(OuterWithPrefixedNullableEmbeddedType.class, template);
SchemaTestUtils.createTableAndTypes(WithMappedUdtList.class, template);
SchemaTestUtils.truncate(User.class, template);
SchemaTestUtils.truncate(UserToken.class, template);
SchemaTestUtils.truncate(BookReference.class, template);
SchemaTestUtils.truncate(TypeWithCompositeKey.class, template);
SchemaTestUtils.truncate(WithNullableEmbeddedType.class, template);
SchemaTestUtils.truncate(WithEmptyEmbeddedType.class, template);
SchemaTestUtils.truncate(WithPrefixedNullableEmbeddedType.class, template);
SchemaTestUtils.truncate(OuterWithNullableEmbeddedType.class, template);
SchemaTestUtils.truncate(OuterWithPrefixedNullableEmbeddedType.class, template);
SchemaTestUtils.truncate(WithMappedUdtList.class, template);
}
use of org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver in project spring-data-cassandra by spring-projects.
the class CassandraTemplateProducer method createCassandraOperations.
@Produces
@ApplicationScoped
public CassandraOperations createCassandraOperations(CqlSession session) throws Exception {
CassandraMappingContext mappingContext = new CassandraMappingContext();
mappingContext.setUserTypeResolver(new SimpleUserTypeResolver(session));
mappingContext.afterPropertiesSet();
MappingCassandraConverter cassandraConverter = new MappingCassandraConverter(mappingContext);
cassandraConverter.afterPropertiesSet();
return new CassandraAdminTemplate(session, cassandraConverter);
}
use of org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver in project spring-boot by spring-projects.
the class CassandraDataAutoConfiguration method cassandraConverter.
@Bean
@ConditionalOnMissingBean
public CassandraConverter cassandraConverter(CassandraMappingContext mapping, CassandraCustomConversions conversions) {
MappingCassandraConverter converter = new MappingCassandraConverter(mapping);
converter.setCodecRegistry(this.session.getContext().getCodecRegistry());
converter.setCustomConversions(conversions);
converter.setUserTypeResolver(new SimpleUserTypeResolver(this.session));
return converter;
}
Aggregations