private static CassandraConverter toConverter(CassandraOperations operations) { Assert.notNull(operations, "CassandraOperations must not be null"); return operations.getConverter(); }
/** * Create a {@link Insert} statement containing all properties including these with {@literal null} values. * * @param entity the entity, must not be {@literal null}. * @return the constructed {@link Insert} statement. * @deprecated since 2.1, use {@link InsertOptions#isInsertNulls()} with * {@link CassandraOperations#insert(Object, InsertOptions)}. */ protected <S extends T> Insert createInsert(S entity) { return InsertUtil.createInsert(operations.getConverter(), entity); }
/** * Create a new {@link CassandraRepositoryFactory} with the given {@link CassandraOperations}. * * @param operations must not be {@literal null} */ public CassandraRepositoryFactory(CassandraOperations operations) { Assert.notNull(operations, "CassandraOperations must not be null"); this.operations = operations; this.mappingContext = operations.getConverter().getMappingContext(); }
@Override @SuppressWarnings("unchecked") public <T, ID> CassandraEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) { CassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(domainClass); return new MappingCassandraEntityInformation<>((CassandraPersistentEntity<T>) entity, operations.getConverter()); }
@Override public CassandraBatchOperations update(Iterable<?> entities, WriteOptions options) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); Assert.notNull(options, "WriteOptions must not be null"); for (Object entity : entities) { Assert.notNull(entity, "Entity must not be null"); batch.add(QueryUtils.createUpdateQuery(getTableName(entity), entity, options, operations.getConverter())); } return this; }
@Override public CassandraBatchOperations insert(Iterable<?> entities, WriteOptions options) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); Assert.notNull(options, "WriteOptions must not be null"); CassandraMappingContext mappingContext = operations.getConverter().getMappingContext(); for (Object entity : entities) { Assert.notNull(entity, "Entity must not be null"); BasicCassandraPersistentEntity<?> persistentEntity = mappingContext .getRequiredPersistentEntity(entity.getClass()); batch.add(QueryUtils.createInsertQuery(persistentEntity.getTableName().toCql(), entity, options, operations.getConverter(), persistentEntity)); } return this; }
@Override public CassandraBatchOperations delete(Iterable<?> entities) { assertNotExecuted(); Assert.notNull(entities, "Entities must not be null"); for (Object entity : entities) { Assert.notNull(entity, "Entity must not be null"); batch.add( QueryUtils.createDeleteQuery(getTableName(entity), entity, QueryOptions.empty(), operations.getConverter())); } return this; }
/** * Create a new {@link PartTreeCassandraQuery} from the given {@link QueryMethod} and {@link CassandraTemplate}. * * @param queryMethod must not be {@literal null}. * @param operations must not be {@literal null}. */ public PartTreeCassandraQuery(CassandraQueryMethod queryMethod, CassandraOperations operations) { super(queryMethod, operations); this.tree = new PartTree(queryMethod.getName(), queryMethod.getResultProcessor().getReturnedType().getDomainType()); this.mappingContext = operations.getConverter().getMappingContext(); this.statementFactory = new StatementFactory(new UpdateMapper(operations.getConverter())); }
private Class<?> resolveResultType(ResultProcessor resultProcessor) { CassandraReturnedType returnedType = new CassandraReturnedType(resultProcessor.getReturnedType(), getOperations().getConverter().getCustomConversions()); return returnedType.isProjecting() ? returnedType.getDomainType() : returnedType.getReturnedType(); }