Search in sources :

Example 1 with Mapper

use of com.datastax.oss.driver.api.mapper.annotations.Mapper in project java-driver by datastax.

the class ImmutableEntityIT method setup.

@BeforeClass
public static void setup() {
    CqlSession session = SESSION_RULE.session();
    for (String query : createStatements(CCM_RULE)) {
        session.execute(SimpleStatement.builder(query).setExecutionProfile(SESSION_RULE.slowProfile()).build());
    }
    UserDefinedType dimensions2d = session.getKeyspace().flatMap(ks -> session.getMetadata().getKeyspace(ks)).flatMap(ks -> ks.getUserDefinedType("dimensions2d")).orElseThrow(AssertionError::new);
    session.execute("INSERT INTO product2d (id, description, dimensions) VALUES (?, ?, ?)", PRODUCT_2D_ID, "2D product", dimensions2d.newValue(12, 34));
    InventoryMapper mapper = InventoryMapper.builder(session).build();
    dao = mapper.immutableProductDao(SESSION_RULE.keyspace());
}
Also used : CqlIdentifier(com.datastax.oss.driver.api.core.CqlIdentifier) DaoFactory(com.datastax.oss.driver.api.mapper.annotations.DaoFactory) BeforeClass(org.junit.BeforeClass) DaoKeyspace(com.datastax.oss.driver.api.mapper.annotations.DaoKeyspace) TestRule(org.junit.rules.TestRule) Mapper(com.datastax.oss.driver.api.mapper.annotations.Mapper) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) CcmRule(com.datastax.oss.driver.api.testinfra.ccm.CcmRule) SimpleStatement(com.datastax.oss.driver.api.core.cql.SimpleStatement) ParallelizableTests(com.datastax.oss.driver.categories.ParallelizableTests) FLUENT(com.datastax.oss.driver.api.mapper.entity.naming.GetterStyle.FLUENT) Computed(com.datastax.oss.driver.api.mapper.annotations.Computed) Entity(com.datastax.oss.driver.api.mapper.annotations.Entity) CqlSession(com.datastax.oss.driver.api.core.CqlSession) MapperBuilder(com.datastax.oss.driver.api.mapper.MapperBuilder) Select(com.datastax.oss.driver.api.mapper.annotations.Select) PropertyStrategy(com.datastax.oss.driver.api.mapper.annotations.PropertyStrategy) ClassRule(org.junit.ClassRule) Row(com.datastax.oss.driver.api.core.cql.Row) PartitionKey(com.datastax.oss.driver.api.mapper.annotations.PartitionKey) DefaultNullSavingStrategy(com.datastax.oss.driver.api.mapper.annotations.DefaultNullSavingStrategy) Test(org.junit.Test) CqlName(com.datastax.oss.driver.api.mapper.annotations.CqlName) Insert(com.datastax.oss.driver.api.mapper.annotations.Insert) UUID(java.util.UUID) Category(org.junit.experimental.categories.Category) UdtValue(com.datastax.oss.driver.api.core.data.UdtValue) SessionRule(com.datastax.oss.driver.api.testinfra.session.SessionRule) Objects(java.util.Objects) RuleChain(org.junit.rules.RuleChain) UserDefinedType(com.datastax.oss.driver.api.core.type.UserDefinedType) GetEntity(com.datastax.oss.driver.api.mapper.annotations.GetEntity) NullSavingStrategy(com.datastax.oss.driver.api.mapper.entity.saving.NullSavingStrategy) Dao(com.datastax.oss.driver.api.mapper.annotations.Dao) UserDefinedType(com.datastax.oss.driver.api.core.type.UserDefinedType) CqlSession(com.datastax.oss.driver.api.core.CqlSession) BeforeClass(org.junit.BeforeClass)

Aggregations

CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)1 CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 Row (com.datastax.oss.driver.api.core.cql.Row)1 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)1 UdtValue (com.datastax.oss.driver.api.core.data.UdtValue)1 UserDefinedType (com.datastax.oss.driver.api.core.type.UserDefinedType)1 MapperBuilder (com.datastax.oss.driver.api.mapper.MapperBuilder)1 Computed (com.datastax.oss.driver.api.mapper.annotations.Computed)1 CqlName (com.datastax.oss.driver.api.mapper.annotations.CqlName)1 Dao (com.datastax.oss.driver.api.mapper.annotations.Dao)1 DaoFactory (com.datastax.oss.driver.api.mapper.annotations.DaoFactory)1 DaoKeyspace (com.datastax.oss.driver.api.mapper.annotations.DaoKeyspace)1 DefaultNullSavingStrategy (com.datastax.oss.driver.api.mapper.annotations.DefaultNullSavingStrategy)1 Entity (com.datastax.oss.driver.api.mapper.annotations.Entity)1 GetEntity (com.datastax.oss.driver.api.mapper.annotations.GetEntity)1 Insert (com.datastax.oss.driver.api.mapper.annotations.Insert)1 Mapper (com.datastax.oss.driver.api.mapper.annotations.Mapper)1 PartitionKey (com.datastax.oss.driver.api.mapper.annotations.PartitionKey)1 PropertyStrategy (com.datastax.oss.driver.api.mapper.annotations.PropertyStrategy)1 Select (com.datastax.oss.driver.api.mapper.annotations.Select)1