use of org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver 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