Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

JNoSQL/Diana/OrientDB

< JNoSQL‎ | Diana

OrientDB

OrientDB is an open source NoSQL database management system written in Java. It is a multi-model database, supporting graph, document, key/value, and object models, but the relationships are managed as in graph databases with direct connections between records. It supports schema-less, schema-full and schema-mixed modes. It has a strong security profiling system based on users and roles and supports querying with Gremlin along with SQL extended for graph traversal. OrientDB uses several indexing mechanisms based on B-tree and Extendible hashing, the last one is known as "hash index", there are plans to implement LSM-tree and Fractal tree index based indexes. Each record has Surrogate key which indicates position of record inside of Array list , links between records are stored either as single value of record's position stored inside of referrer or as B-tree of record positions (so-called record IDs or RIDs) which allows fast traversal (with O(1) complexity) of one-to-many relationships and fast addition/removal of new links. OrientDB is the second most popular graph database according to the DB-Engines graph database ranking

Maven Project

To use OrientDB driver in a Maven Project:

        <dependency>
            <groupId>org.jnosql.diana</groupId>
            <artifactId>orientdb-driver</artifactId>
            <version>version</version>
        </dependency>

E.g:

        <dependency>
            <groupId>org.jnosql.diana</groupId>
            <artifactId>orientdb-driver</artifactId>
            <version>0.0.1</version>
        </dependency>


Document

The Orientdb document implementation uses the MongoDBDocumentConfiguration to the configuration. Beyond the method also it can read a configuration from diana-orientdb.properties file.


  • orientdb-server-host: the host
  • orientdb-server-user: the user
  • orientdb-server-password: the password
  • orientdb-server-storageType: the storage type

Sample Code


public class App {

    public static final String DATABASE = "database";
    public static final String DOCUMENT_COLLECTION = "person";

    public static void main(String[] args)  {
        DocumentConfiguration configuration = new OrientDBDocumentConfiguration();
        try(DocumentCollectionManagerFactory collectionFactory = configuration.get();) {
            DocumentCollectionManager collectionManager = collectionFactory.get(DATABASE);

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

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

            DocumentQuery query = select.from(DOCUMENT_COLLECTION).where(DocumentCondition.eq(id.get());
            List<DocumentEntity> documentsFound = collectionManager.select(query);


        }
    }
}

Links

Back to the top