Skip to main content
Jump to: navigation, search

JNoSQL/Diana

Eclipse JNoSQL Diana

Duke-diana-min.png

With the strategy to divide and conquer on JNoSQL. The Diana was born, it has the goal to be the communication layer easy and extensible. The extensibility is more than important, that is entirely necessary once the API must support specific feature at each database. Nonetheless, the advantage of a common API is a change to another database provider has lesser than using the specific API.


To cover the four kinds of database, this API has four packages, one for each data bank.

  • org.jnosql.diana.column
  • org.jnosql.diana.document
  • org.jnosql.diana.graph
  • org.jnosql.diana.key


So, if a database is multi-model, has support to more than one database, it will implement an API to each database which it supports. Also, each API has the TCK to prove if the database is compatible with the API. Even from differents JSR it tries to use the same nomenclature:

  • Configuration
  • Factory
  • Manager
  • Entity
  • Element Entity
  • Value


Value

This interface represents the value that will store, that is a wrapper to be a bridge between the database and the application. Eg. If a database does not support a Java type, it may do the conversion with easily.

        Value value = Value.of(12);
        String string = value.get(String.class);
        List<Integer> list = value.get(new TypeReference<List<Integer>>() {});
        Set<Long> set = value.get(new TypeReference<Set<Long>>() {});
        Stream<Integer> stream = value.get(new TypeReference<Stream<Integer>>() {});
        Object integer = value.get();


Element Entity

The Element entity is a small piece of a body, except a key-value structure type once this structure is simple. Eg. The column family structure, the entity, has columns, element entity, with column has a tuple where the key is the name, and the value is the information as a Value implementation.

        Document document = Document.of("name", "value");
        Value value = document.getValue();
        String name = document.getName();

        Column document = Column.of("name", "value");
        Value value = document.getValue();
        String name = document.getName();


Entity

The Entity is the body of the information that goes to the database; each database has an Entity:

  • ColumnFamilyEntity
  • DocumentCollectionEntity
  • KeyValueEntity


ColumnFamilyEntity

ColumnFamilyEntity entity = ColumnFamilyEntity.of("columnFamily"); 
entity.add(Column.of("id", Value.of(10L))); 
entity.add(Column.of("version", 0.001)); 
entity.add(Column.of("name", "Diana")); 
entity.add(Column.of("options", Arrays.asList(1, 2, 3))); 

List<Column> columns = entity.getColumns(); 
Optional<Column> id = entity.find("id");


DocumentCollectionEntity

        ColumnEntity entity = ColumnEntity.of("columnFamily");
        String name = entity.getName();
        entity.add(Column.of("id", Value.of(10L)));
        entity.add(Column.of("version", 0.001));
        entity.add(Column.of("name", "Diana"));
        entity.add(Column.of("options", Arrays.asList(1, 2, 3)));

        List<Column> columns = entity.getColumns();
        Optional<Column> id = entity.find("id");
        entity.remove("options");

KeyValueEntity

KeyValueEntity<String> entity = KeyValueEntity.of("key", Value.of(123));
KeyValueEntity<Integer> entity2 = KeyValueEntity.of(12, "Text");
String key = entity.getKey();
Value value = entity.getValue();
Integer integer = entity.get(Integer.class);


Manager

The Manager is the class that pushes information to a database and retrieves it. The manager might have a synchronous and asynchronous implementation.


Factory

The factory class creates the Managers.

Configuration

The configuration classes create a Manager Factory. This class has all the configuration to build the database connection.




Links

Back to the top