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

 

question

vikram.singh.chouhan_187371 avatar image
vikram.singh.chouhan_187371 asked ·

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.

    @Mapper
    //@AutoService(Processor.class)
    public interface InventoryMapperBuilder
    // extends Processor
    {
        static MapperBuilder<InventoryMapperBuilder> builder(CqlSession session) {
            return new InventoryMapperBuilder(session);
          }

        @DaoFactory
        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/ItemPriceByMaterialMapper.java:[21,19] error: cannot find symbol
  symbol:   class ItemPriceByMaterialMapperBuilder
  location: interface ItemPriceByMaterialMapper

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
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.

driverjava
1 comment
10 |1000 characters needed characters left characters exceeded

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 characters needed characters left characters exceeded

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 · ·