JNoSQL

JNoSQL is a flexible and extensible Java API for connecting with NoSQL databases. It brings an easy interface to support key-value, column family, document oriented and graph databases as JDBC does for SQL databases.


About


The JNoSQL is a several tools to make easy an integration between the Java Application with the NoSQL. The project has two layers:

The basic building blocks hereby are:

The API's focus is on simplicity and ease of use. Developers should only have to know a minimal set of artifacts to work with the solution. The API is built on latest Java 8 features and therefore fit perfectly with the functional features of Java 8.

Diana

The Diana project has as goal just be the low layer, in other words, just the communication layer to NoSQL database. Basically this project works as a database driver. Diana have four APIs, one for each database type, and its TCK respective. The test compatibility kit affirms if a driver implements an API correctively. So a X database of key-value implements and run all tests correctively that means this X database has support to key-value Diana API.

Artemis

Artemis is an integration layer, in other words, it has the goal to communicate with the communication layer, Diana, and it does integrations with other technologies such as Bean Validation. The Artemis engine has CDI. So it formula is really simple:

Diana plus CDI equals to Artemis

Look like Diana, it has a different package to each NoSQL database. Using CDI as heart, Artemis is highly customizable also observe events on the persistence flow. Artemis has a nice feature such as:

Using CDI events to add a new feature on Artemis is so easy and you also can it on transparency way, you don't need to change the repositories. E.G: Using events can add bean validation on the workflow, without the DAO layer know.

Support


Currently, JNoSQL works with the following databases:

Examples


Here you can see some examples of usage of Diana.

        

          public class AppDocument {

            private static final String DOCUMENT_COLLECTION = "document_collection";
            private static final String DATABASE = "database";

            public static void main(String[] args)  {
              DocumentConfiguration configuration = //any implementation
              try(DocumentCollectionManagerFactory collectionFactory = configuration.getManagerFactory();) {
                DocumentCollectionManager collectionManager = collectionFactory.getDocumentEntityManager(DATABASE);

                DocumentCollectionEntity entity = DocumentCollectionEntity.of(DOCUMENT_COLLECTION);
                entity.add(Document.of("name", "Daniel Soro"));
                entity.add(Document.of("age", 26));

                DocumentCollectionEntity entitySaved = collectionManager.insert(entity);
                Optional<Document> id = entitySaved.find("_id");


                DocumentQuery query = select().from(DOCUMENT_COLLECTION).where(eq(id.get())).build();
                List<DocumentCollectionEntity> documentsFound = collectionManager.find(query);

              }
            }
          }
        
      

        

          public class AppColumn {

            private static final String KEY_SPACE = "newKeySpace";
            private static final String COLUMN_FAMILY = "newColumnFamily";

            public static void main(String[] args) {

              ColumnConfiguration condition = //any implementation

              try(ColumnFamilyManagerFactory managerFactory = condition.getManagerFactory()) {
                ColumnFamilyManager columnEntityManager = managerFactory.getColumnEntityManager(KEY_SPACE);
                ColumnFamilyEntity entity = ColumnFamilyEntity.of(COLUMN_FAMILY);
                Column id = Column.of("id", 10L);
                entity.add(id);
                entity.add(Column.of("version", 0.001));
                entity.add(Column.of("name", "Diana"));
                entity.add(Column.of("options", Arrays.asList(1, 2, 3)));

                columnEntityManager.insert(entity);

                DocumentQuery query = select().from(COLUMN_FAMILY).where(eq(id)).build();
                List<ColumnFamilyEntity> entities = columnEntityManager.find(query);

              }


            }
          
        

          

            public class AppKeyValue {


              public static void main(String[] args) {

                KeyValueConfiguration configuration = //any implementation
                try (BucketManagerFactory managerFactory = configuration.getManagerFactory()) {
                  BucketManager bucket = managerFactory.getBucketManager("bucket");
                  List<String> list = managerFactory.getList("bucketList", String.class);
                  Set<String> set = managerFactory.getSet("bucketSet", String.class);
                  Map<String, Integer> map = managerFactory.getMap("bucketList", String.class, Integer.class);
                  Queue<String> queue = managerFactory.getQueue("queueList", String.class);
                  bucket.put("key", "value");
                  Optional<Value> value = bucket.get("key");
                }


              }
            }
          
        
See more Read the JNoSQL book

Download


Diana is a flexible and extensible API to connect NoSQL databases. It brings an easy interface to support key-value, column family, document oriented and graph databases as JDBC does for SQL databases.

View on GitHub

Join Us


Meet the developers, and stay tunned on the news about Diana development. You may want to become one of us!

Join Us Mailing list Wiki