cassandra-caseclass-adapter


License

License

Categories

Categories

Cassandra Data Databases Net React User Interface Web Frameworks
GroupId

GroupId

net.reactivecore
ArtifactId

ArtifactId

cassandra-caseclass-adapter_2.11
Last Version

Last Version

0.0.2
Release Date

Release Date

Type

Type

jar
Description

Description

cassandra-caseclass-adapter
cassandra-caseclass-adapter
Project URL

Project URL

https://github.com/reactivecore/cassandra_caseclass_adapter
Project Organization

Project Organization

net.reactivecore
Source Code Management

Source Code Management

https://github.com/reactivecore/cassandra_caseclass_adapter

Download cassandra-caseclass-adapter_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/net.reactivecore/cassandra-caseclass-adapter_2.11/ -->
<dependency>
    <groupId>net.reactivecore</groupId>
    <artifactId>cassandra-caseclass-adapter_2.11</artifactId>
    <version>0.0.2</version>
</dependency>
// https://jarcasting.com/artifacts/net.reactivecore/cassandra-caseclass-adapter_2.11/
implementation 'net.reactivecore:cassandra-caseclass-adapter_2.11:0.0.2'
// https://jarcasting.com/artifacts/net.reactivecore/cassandra-caseclass-adapter_2.11/
implementation ("net.reactivecore:cassandra-caseclass-adapter_2.11:0.0.2")
'net.reactivecore:cassandra-caseclass-adapter_2.11:jar:0.0.2'
<dependency org="net.reactivecore" name="cassandra-caseclass-adapter_2.11" rev="0.0.2">
  <artifact name="cassandra-caseclass-adapter_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.reactivecore', module='cassandra-caseclass-adapter_2.11', version='0.0.2')
)
libraryDependencies += "net.reactivecore" % "cassandra-caseclass-adapter_2.11" % "0.0.2"
[net.reactivecore/cassandra-caseclass-adapter_2.11 "0.0.2"]

Dependencies

compile (4)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
com.chuusai : shapeless_2.11 jar 2.3.3
com.datastax.oss : java-driver-core jar 4.7.2
com.datastax.oss : java-driver-query-builder jar 4.7.2

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 3.0.9

Project Modules

There are no modules declared in this project.

Cassandra Case Class Adapters

Build Status

Maps Case classes to the Cassandra Java Driver using shapeless powered type classes.

Note:

  • this is in early development stage
  • contains weird hacks and class casts
  • not API stable

Thanks a lot to the Shapeless team for their wonderful work.

Add Dependency

Builds are available for Scala 2.11, 2.12 having a dependency to the Cassandra Driver 4.7.2.

Add this to your build.sbt:

libraryDependencies += "net.reactivecore" %% "cassandra-caseclass-adapter" % "0.0.2"

If you use Scala 2.10, you also need (see Shapeless Documentation)

libraryDependencies += compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)

Usage

Define a case class

case class Person (
    id: UUID,
    name: String,
    age: Int
  )

Have a cassandra table

  CREATE TABLE persons (
    id UUID,
    name TEXT,
    age INT,
    PRIMARY KEY (id)
  );

And let the Adapter automatically generated

  import net.reactivecore.cca.CassandraCaseClassAdapter

  val adapter = CassandraCaseClassAdapter.make[Person]("persons")
  val session = // open cassandra session
  val person = Person(UUIDs.random(), "John Doe", 42)
  adapter.insert(person, session)
  
  val back: Seq[Person] = adapter.loadAllFromCassandra(session)

Supported

  • boiler plate free fromRow, insert, loadAllFromCassandra

Supported Types

  • Most fundamental types
  • Option
  • Set of Primitives and of UDT
  • List of Primitives (as Seq) and of UDT
  • Primitive UDT handling

Not supported / tested yet

  • Map
  • Tuples
  • Combination of Set/Seq with more than one UDT
  • Adding custom types
  • Prepared Statements for fast insert

Not planned (yet)

  • Query Helpers

Testing

  • The unit tests need a Cassandra Instance running on 127.0.0.1
  • They will recreate a keyspace called unittest on each single testcase.
net.reactivecore

Reactive Core GmbH

Versions

Version
0.0.2
0.0.1