Skip to content
lvca edited this page Dec 22, 2012 · 2 revisions

Java APIs

Java APIs

OrientDB is written 100% in Java. You can use the native Java APIs without any driver or adapter.

First of all need to choose the database type to use by checking what you need:

Database types

Type Use this if Description Java class Query Dictionary Schema Less Schema full **Speed** *
Object-Database If you need a full **Object Oriented** abstraction that binds all the database entities to **POJO** (Plain Old Java Object) The higher level database. Able to store and retrieve POJOs transparently. Under the hood, it uses the Document Database to store object information. Can be used in schema-less or schema-based modes [OObjectDatabaseTx](http://www.orientdb.org/releases/latest/javadoc/com/orientechnologies/orient/object/db/OObjectDatabaseTx.html) Yes Yes Yes Yes 40%
TinkerPop Graph Database If you work with **graphs** and want your code **portable** across **TinkerPop Blueprints** implementations The bridge to use OrientDB with all [TinkerPop technologies](http://www.tinkerpop.com) OrientGraph Yes Yes Yes Yes 45%
High-Level Graph Database Will be **deprecated** in future releases. Use GraphDatabaseRaw or GraphDatabaseTinkerpop instead. The high level GraphDB API uses OGraphVertex and OGraphEdge classes. [ODatabaseGraphTx](http://www.orientechnologies.com/releases/latest/javadoc/index.html?com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.html) Yes Yes Yes Yes 55%
Raw Graph Database If you work with **graphs** and need maximum **performance**. The lower level of GraphDB API. Directly uses ODocument objects. [OGraphDatabase](http://www.orientechnologies.com/releases/latest/javadoc/index.html?com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.html) Yes Yes Yes Yes 70%
Document-Database if you need **high performance** and/or work with **schema-less structures**. Handles records as documents. Documents are comprised of fields. Fields can be any of the types supported. Does not need a Java domain POJO, as required for the Object Database. Can be used as schema-less or schema-base modes [ODatabaseDocumentTx](http://www.orientechnologies.com/releases/latest/javadoc/index.html?com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.html) Yes Yes Yes Yes 70%
Flat Database If you need **maximum performance** at the cost of having all records represented merely as Strings Flat record database that manages string contents. No Query capability at all, just direct access to records as strings [ODatabaseFlat](http://www.orientechnologies.com/releases/latest/javadoc/index.html?com/orientechnologies/orient/core/db/document/ODatabaseDocumentTx.html) No Yes Yes No 100%

* Speed comparison for generic CRUD operations such as query, insertion, update and deletion. Larger is better. 100% is fastest. In general the price of a high level of abstraction is a speed penalty, but remember that Orient is orders of magnitude faster than the classic RDBMS. So using the Object Database gives you a high level of abstraction with much less code to develop and mantain.

!JavaDoc

Browse the Orient DB API JavaDoc.

Which library do I use?

OrientDB comes with some jar files contained in the lib directory

JAR name Description **When required?** Depends on 3rd party jars
orient-commons-**.jar Library with some utility classes that are not part of OrientDB itself but usable with any kind of project Always
orientdb-core-**.jar Core library Always
orientdb-client-**.jar Remote client When your application talks with a remote server
orientdb-enterprise-**.jar Base package with the protocol and network classes shared by client and server When your application talks with a remote server
orientdb-server-**.jar Server component It's used by the server component. Include it only if you're embedding a server
orientdb-tools-**.jar Contain the console and console commands Never, unless you want to execute console command directly by your application. Used by the console application
orientdb-object-**.jar Contain the Object Database interface Include it if you're using this interface javassist.jar, persistence-api-1.0.jar

Engines

OrientDB supports pluggable engines. The engine is the first part of the database URL. By default the "local" and "memory" are self-registered, while the "remote" requires to link the orient-client.jar library in your classpath.

Multi-threading

None of the database classes are thread-safe. For this reason use different Database instances in each thread. The local client cache is shared between all threads. When your client is connected to a remote OrientDB Server instance it is always best to work inside a transaction. In this way local changes will only be transmitted at commit time while transactions continue to see local changes. For more information: Multi Threading.

Schema APIs

If you are using a database that supports a schema (see the table above), check the Schema APIs page. Schema APIs are common to all databases that support this feature.

Hooks

Starting from v. 0.9.16 OrientDB supports hooks. Hook works like a trigger. Hook lets the user application intercept internal events. See Hook API.

Clone this wiki locally