Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started



vikram.singh.chouhan_187371 avatar image
vikram.singh.chouhan_187371 asked Erick Ramirez edited

What is the right way to use mapper notation with cassandra DB store?

I am currently working on a new project and chose Cassandra as our data store. I have a use case where I store prices for material and to accomplish it I created a list of User-Defined Types (UDTs).

I tried using Object Mapper from java driver itself but got stuck at one point where creating an object using InventoryMapperBuilder is throwing compilation error. Is anything additional required towards annotation processing or am I missing something? is it the right way to use Mapper annotation? please check the code snippet below. I also tried using google's AutoService to achieve annotation processing externally but no success yet.

    public interface InventoryMapperBuilder
    // extends Processor
        static MapperBuilder<InventoryMapperBuilder> builder(CqlSession session) {
            return new InventoryMapperBuilder(session);

        ItemPriceByMaterialDao itemPriceByMaterialDao ();

        // @DaoFactory
        // ItemPriceByMaterialDao itemPriceByMaterialDao(@DaoKeyspace CqlIdentifier
        // keyspace);

I raised the same at StackOverflow also. Thanks

Version used:

Java Version: 1.8.0_221

DataStax OSS java-driver-mapper-processor: 4.5.1

DataStax OSS java-driver-mapper-runtime: 4.5.1

Cassandra: 3.11.4

Spring Boot Framework: 2.2.4.RELEASE

Below is the compilation error stack trace:

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project pricing-api: Compilation failure
/Users/i341306/workstation/pricingDB/codebase/PRICINGDB/pricingservice/api/src/main/java/ariba/pricing/cassandra/api/model/price/[21,19] error: cannot find symbol
  symbol:   class ItemPriceByMaterialMapperBuilder
  location: interface ItemPriceByMaterialMapper

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (
    at (
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (
    at org.apache.maven.DefaultMaven.doExecute (
    at org.apache.maven.DefaultMaven.doExecute (
    at org.apache.maven.DefaultMaven.execute (
    at org.apache.maven.cli.MavenCli.execute (
    at org.apache.maven.cli.MavenCli.doMain (
    at org.apache.maven.cli.MavenCli.main (
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (
    at java.lang.reflect.Method.invoke (
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure

These are my console logs. Let me know if any other additional info is required.

1 comment
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

i decided not to use object mapper and work with Spring Data Cassandra. Thanks

0 Likes 0 ·

1 Answer

alexandre.dutra avatar image
alexandre.dutra answered

You are using incompatible libraries. DataStax driver 4.5.1 is not compatible with Spring Boot 2.2.4.

The following combinations should work:

  1. DataStax driver 4.5.x and Spring Boot 2.3.0.M3
  2. DataStax driver 3.7.x or 3.8.x and Spring Boot 2.2.x

Please fix this first and the we should be able to help you with the mapper.

4 comments Share
10 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thanks @alexandre.dutra i will try your suggestion.

0 Likes 0 ·

Hi @alexandre.dutra: I tried using DataStax driver 4.5.x and Spring Boot 2.3.0.M3 but it didn't solve my problem. Thanks

0 Likes 0 ·
alexandre.dutra avatar image alexandre.dutra ♦ vikram.singh.chouhan_187371 ·

OK, can you please share what compilation error you are seeing, and what is the stack trace? Thanks!

0 Likes 0 ·

Hi @alexandre.dutra i updated the stack trace in original question above. Thanks

0 Likes 0 ·