Search in sources :

Example 1 with EmbeddedEntityOperations

use of org.springframework.data.cassandra.core.mapping.EmbeddedEntityOperations in project spring-data-cassandra by spring-projects.

the class SchemaTestUtils method potentiallyCreateUdtFor.

private static void potentiallyCreateUdtFor(CassandraPersistentEntity<?> persistentEntity, CassandraOperations operations, SchemaFactory schemaFactory) {
    if (persistentEntity.isUserDefinedType()) {
        CreateUserTypeSpecification udtspec = schemaFactory.getCreateUserTypeSpecificationFor(persistentEntity).ifNotExists();
        operations.getCqlOperations().execute(CreateUserTypeCqlGenerator.toCql(udtspec));
    } else {
        for (CassandraPersistentProperty property : persistentEntity) {
            if (!property.isEntity()) {
                continue;
            }
            if (property.isEmbedded()) {
                potentiallyCreateUdtFor(new EmbeddedEntityOperations(operations.getConverter().getMappingContext()).getEntity(property), operations, schemaFactory);
            } else {
                potentiallyCreateUdtFor(operations.getConverter().getMappingContext().getRequiredPersistentEntity(property), operations, schemaFactory);
            }
        }
    }
}
Also used : CreateUserTypeSpecification(org.springframework.data.cassandra.core.cql.keyspace.CreateUserTypeSpecification) EmbeddedEntityOperations(org.springframework.data.cassandra.core.mapping.EmbeddedEntityOperations) CassandraPersistentProperty(org.springframework.data.cassandra.core.mapping.CassandraPersistentProperty)

Aggregations

CreateUserTypeSpecification (org.springframework.data.cassandra.core.cql.keyspace.CreateUserTypeSpecification)1 CassandraPersistentProperty (org.springframework.data.cassandra.core.mapping.CassandraPersistentProperty)1 EmbeddedEntityOperations (org.springframework.data.cassandra.core.mapping.EmbeddedEntityOperations)1