use of org.springframework.data.cassandra.core.mapping.UserTypeResolver 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.UserTypeResolver in project spring-data-cassandra by spring-projects.
the class AbstractCassandraConfiguration method cassandraMapping.
/**
* Return the {@link MappingContext} instance to map Entities to {@link Object Java Objects}.
*
* @throws ClassNotFoundException if the Cassandra Entity class type identified by name
* cannot be found during the scan.
* @see org.springframework.data.cassandra.core.mapping.CassandraMappingContext
*/
@Bean
public CassandraMappingContext cassandraMapping() throws ClassNotFoundException {
CqlSession cqlSession = getRequiredSession();
UserTypeResolver userTypeResolver = new SimpleUserTypeResolver(cqlSession, CqlIdentifier.fromCql(getKeyspaceName()));
CassandraMappingContext mappingContext = new CassandraMappingContext(userTypeResolver, SimpleTupleTypeFactory.DEFAULT);
CustomConversions customConversions = requireBeanOfType(CassandraCustomConversions.class);
getBeanClassLoader().ifPresent(mappingContext::setBeanClassLoader);
mappingContext.setCodecRegistry(cqlSession.getContext().getCodecRegistry());
mappingContext.setCustomConversions(customConversions);
mappingContext.setInitialEntitySet(getInitialEntitySet());
mappingContext.setSimpleTypeHolder(customConversions.getSimpleTypeHolder());
return mappingContext;
}
Aggregations