architecture/design/spring-data-yugabytedb.md
Spring Data modules are one of the widely used Java frameworks for accessing the databases. Spring data provides consistent and familiar APIs for querying the data by supporting Data repository, template methods. For app developers these common set of APIs provided by Spring Data abstracts away the need to learn the database-specific query language, reducing the learning curve required for working with a database.
Spring Data YugabyteDB modules intend to bring support for YugabyteDB YSQL and YCQL API for building modern cloud native applications. For application developers, Spring Data YugabyteDB will bridge the gap for learning the distributed SQL concepts with familiarity and ease of Spring Data APIs.
spring.data.yugabytedb.ysql.*spring.data.yugabytedb.ycql.*Spring Data YugabyteDB (SDYB) is a top-level project which provides support for both YCQL and YSQL APIs. SDYB will have two projects,
Spring Data YugabyteDB will have the parent project BOM which will include both these dependencies.
<dependency>
<groupId>com.yugabyte</groupId>
<artifactId>spring-data-yugabytedb-dependencies</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
Spring Data projects should support following database specific configurations,
@enableyugabyteycqlrepositories and @enabletransactionsupport annotationSpring Data JDBC module provides JDBC template and JDBC repository implementation for relational databases with JDBC access. Spring Data JDBC is not an JPA compliant ORM provider, it's a very lightweight implementation provided by Spring team.
<dependency>
<groupId>com.yugabyte</groupId>
<artifactId>spring-data-yugabytedb-ysql</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
Implement a YugabyteDB YSQL dialect to support YSQL specific features a. YB specific annotations for entity mapping and field mapping - Primary key (Hash/Range) - Compound keys - Data types support
Provide YugabytedbTemplate and YugabytedbRepository implementation a. Transaction support b. Follower Reads support c. Index Support
Implement @enableyugabyteysqlrepositories annotation
YugabyteDB YCQL API is Cassandra CQL compliant API, YCQL is fully compatible with Spring Data Cassandra project with YugabyteDB YCQL Java driver. However, YugabyteDB has support for additional features which require enhancement to Spring Data projects. Here is the list of enhancements,
<dependency>
<groupId>com.yugabyte</groupId>
<artifactId>spring-data-yugabytedb-ycql</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.yugabyte</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.8.0-yb-5</version>
</dependency>
Example:
spring.data.yugabytedb.ycql.keyspace-name=cronos
spring.data.yugabytedb.ycql.contact-points=127.0.0.1
spring.data.yugabytedb.ycql.port=9042
Provide YugabytedbYCQLTemplate and YugabytedbYCQLRepository implementation a. Transaction support b. Index support
Implement @enableyugabyteycqlrepositories and @enabletransactionsupport annotation