Skip to content

alexzender/dbapi-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

dbapi-java

Database API for Java is a lightweight JPA provider implementation for Cassandra. It can also be extended with pluggable modules for other NoSQL document-oriented databases as well.

Overview

The NoSQL field is repidly evolving and changing nowadays. It isn't mature enough and neither standardized yet. This project may help to separate business logic and object model from the database interaction layer. So that it's relatively easy to switch from one vendor to another or support both if any. It becomes possible at certain abstraction overhead though.

Requirements

Build Instructions

The standard build process with Maven is supported.

To build the project from sources and run tests please perform:

$ mvn package

To generate eclipse project files please do:

$ mvn eclipse:eclipse

Usage

The dbapi.api.DBAPI class is an entry point to the system. It provides access to the factory that can issue JPA entity managers. To create a factory you need to specify a map with configuration parameters and the list of persistent entity classes to be managed:

 		
 		Map<String, String> config = new HashMap<String, String>();
        config.put("db.type", "cassandra");
        config.put("plugins.cassandra.keyspace", "tests");
        config.put("plugins.cassandra.host", "localhost");
        config.put("plugins.cassandra.port", "9160");
        
        
        Set<Class<?>> entities = new HashSet<Class<?>>();
        entities.add(User.class);
        
        EntityManagerFactory factory = DBAPI.getFactory(config, entities);

        EntityManager em = factory.createEntityManager();

Please see dbapi.test.system.CRUDTest for more details on Create/Find/Delete commands that are currently supported. In order to play with this test you will need data structures to be pre-created in Cassandra. Use the following script for that:

create keyspace tests;
use tests;

create column family user with
  comparator = UTF8Type and
  column_metadata =
  [
  	{column_name: username, validation_class: UTF8Type},
    {column_name: displayName, validation_class: UTF8Type},
    {column_name: bio, validation_class: UTF8Type},
    {column_name: password, validation_class: UTF8Type}
  ];

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages