use of org.springframework.data.cassandra.core.StatementFactory in project spring-data-cassandra by spring-projects.
the class MappingCassandraConverterTupleIntegrationTests method shouldInsertRowWithComplexTuple.
// DATACASS-523
@Test
void shouldInsertRowWithComplexTuple() {
Person person = new Person();
person.setId("foo");
AddressUserType userType = new AddressUserType();
userType.setZip("myzip");
MappedTuple tuple = new MappedTuple();
tuple.setAddressUserType(userType);
tuple.setCurrency(Arrays.asList(Currency.getInstance("EUR"), Currency.getInstance("USD")));
tuple.setName("bar");
person.setMappedTuple(tuple);
person.setMappedTuples(Collections.singletonList(tuple));
StatementFactory statementFactory = new StatementFactory(new UpdateMapper(converter));
StatementBuilder<RegularInsert> insert = statementFactory.insert(person, WriteOptions.empty());
this.session.execute(insert.build());
}
use of org.springframework.data.cassandra.core.StatementFactory in project spring-data-cassandra by spring-projects.
the class MappingCassandraConverterUDTUnitTests method shouldWriteMappedUdt.
// DATACASS-172
@Test
void shouldWriteMappedUdt() {
AddressUserType addressUserType = prepareAddressUserType();
AddressBook addressBook = new AddressBook();
addressBook.setId("1");
addressBook.setCurrentaddress(addressUserType);
SimpleStatement statement = new StatementFactory(converter).insert(addressBook, WriteOptions.empty()).build(StatementBuilder.ParameterHandling.INLINE);
assertThat(statement.getQuery()).isEqualTo("INSERT INTO addressbook (currentaddress,id) " + "VALUES ({zip:'69469',city:'Weinheim',streetlines:['Heckenpfad','14']},'1')");
}
use of org.springframework.data.cassandra.core.StatementFactory in project spring-data-cassandra by spring-projects.
the class MappingCassandraConverterUDTUnitTests method shouldWriteCompositeUdtPkClass.
// #1137
@Test
void shouldWriteCompositeUdtPkClass() {
WithCompositePrimaryKeyClassWithUdt object = prepareCompositePrimaryKeyClassWithUdt();
SimpleStatement statement = new StatementFactory(converter).insert(object, WriteOptions.empty()).build(StatementBuilder.ParameterHandling.INLINE);
assertThat(statement.getQuery()).isEqualTo("INSERT INTO withcompositeprimarykeyclasswithudt (id,addressusertype,currency) " + "VALUES ('foo',{zip:'69469',city:'Weinheim',streetlines:['Heckenpfad','14']},{currency:'EUR'})");
}
use of org.springframework.data.cassandra.core.StatementFactory in project spring-data-cassandra by spring-projects.
the class MappingCassandraConverterUDTUnitTests method shouldWriteCompositeUdtPk.
// #1137
@Test
void shouldWriteCompositeUdtPk() {
AddressUserType addressUserType = prepareAddressUserType();
WithCompositePrimaryKey withUdt = new WithCompositePrimaryKey();
withUdt.addressUserType = addressUserType;
withUdt.id = "foo";
SimpleStatement statement = new StatementFactory(converter).insert(withUdt, WriteOptions.empty()).build(StatementBuilder.ParameterHandling.INLINE);
assertThat(statement.getQuery()).isEqualTo("INSERT INTO withcompositeprimarykey (id,addressusertype) " + "VALUES ('foo',{zip:'69469',city:'Weinheim',streetlines:['Heckenpfad','14']})");
}
use of org.springframework.data.cassandra.core.StatementFactory in project spring-data-cassandra by spring-projects.
the class MappingCassandraConverterUDTUnitTests method shouldWriteUdtListWithCustomConversion.
// DATACASS-172, DATACASS-400
@Test
void shouldWriteUdtListWithCustomConversion() {
Bank bank = new Bank(null, null, Collections.singletonList(new Currency("EUR")));
SimpleStatement statement = new StatementFactory(converter).insert(bank, WriteOptions.empty()).build(StatementBuilder.ParameterHandling.INLINE);
assertThat(statement.getQuery()).isEqualTo("INSERT INTO bank (othercurrencies) VALUES ([{currency:'EUR'}])");
}
Aggregations