OPAC also provides copy functionality. Data can be loaded into C* table using either POJOs or RDBMS data source tables.

OPAC is built with strict adherence to loose-coupling principle. As you will see in the Pet example below, no part of your Java code extends or implements any OPAC classes or interfaces!

So how is OPAC different from any other Java persistence APIs?

Cassandra is a NoSql database and supports simple one-table queries only. To satisfy complex query requirements it is left up to Java developers to fetch data from multiple tables and compose it into resulting object(s).

This development effort to join, query and compose result let’s say costs N for two tables. Per the graph theory for n number of nodes there are n(n−1)/2 edges. So for a three table scenario, the cost would be 3 x (3-1)/2 = 3 N. For ten tables, it would be 10 x (10-1)/2 = 45 N! For hundred tables, it would be 100 x (100-1)/2= 9900/2=4950 N!

As you can see as the system grows in functionality (number of tables increase) the cost to join, query and compose result increases exponentially. OPAC provides declarative join, query and result computation and thus eliminates middle-tier development effort.

Here Pet, PetHobby and Hobby are defined as components and findByName, findByHobbyID and findByPrimaryKey are the single table queries.

For sub-queries Hobby.findByName and PetHobby.findByHobbyID, OPAC only retrieves columns necessary for joins resulting in higher performance.

Before getting further into details, a quick review of terminology: OPAC is a Java driver that can be invoked from a Java program to access managed objects (defined in schema) and perform CRUD operations. OPAC-Cli is a command-line interface provided to work with OPAC Java driver. Now let’s start with OPAC-Cli.

Now let’s try to add another row to Hobby table by typing the following insert statement at the command prompt:

insert into Hobby (hobbyID, name, description) values (4, 'fly', 'Fly high for no particular reason!');
Note: By no means opac-cli replaces cqlsh! The primary objective for writing opac-cli utility is to provide a development environment for testing and running ad-hoc opac-syntax queries.

The schema defines Hobby.hobbyID as the primary key. So if a record already exists with this hobby it will result in a unique-key violation message, else it will succeed.

As you have seen in this Pet example, no part of your Java code – PetBean, HobbyBean and PetHobbyBean – is extending or implementing any OPAC classes or interfaces!You can simply add a new component to a new module file or to the existing opac-pet-hobby-module.xml and initialize the new component by typing:

initialize schema;

Using OPAC Java Driver

Take a look at DriverUsageExample.java to understand how to save/retrieve Pet objects to/from Cassandra. Run DriverUsageExample as below:

java -cp .:opac-cli-all.jar DriverUsageExample ./opac-config.xml

OPAC Driver Unlimited Production-level Support

Get unlimited production-level support including but not limited to installation, configuration, schema definition, performance tuning, best practices recommendations, and top-priority feature implementation and bug fixes.