Community contributed extensions

OrientDB Module

OrientDB for Play! Framework


These are the default values that you can override in conf/application.conf

# OrientDB Module
# ~~~~~
# odb.url=memory:temp
# odb.user=admin
# odb.password=admin
# Separate url for graphDB, if not specified uses odb.url
# odb.graph.url=memory:temp
# Path to custom configuration file, in classpath or retalive to conf/ dir
# odb.config.file=/play/modules/orientdb/db.config
# Package prefix to scan entities
# odb.entities.package=models
# Control open session in view

Basic usage

Object Database

The access to ODatabaseObjectTx is wrapped in Model, so if you don’t need direct access simply create an entity that extends play.modules.orientdb.Model

public class Item extends Model {
    private Object id;

    private Object version;

    public String name;

    public String description;

And use that entity on the controller:

public class MyController extends Controller {

    public static void index() {
        OObjectIteratorMultiCluster<Item> items = Item.all();

    public static void detail(ORecordId id) {
        Item item = Item.findById(id);

    public static void save(String name, String description) {
        Item item = new Item(); = name;
        item.description = description;;
    public static void search(String query) {
    	List<Item> result = Item.find("select * from Item where name like ?", "%"+query+"%");

Note: to obtain the ORID call the method entity.getIdentity()

Document Database

Inject the session in the controller

public class MyController extends Controller {

    static ODatabaseDocumentTx docdb;


    @Transactional(db = DBTYPE.DOCUMENT)
    public static void good() {
        ODocument doc = new ODocument(docdb, "Account");
        doc.field("name", "good");;


If you have an entity that maps the document you can obtain an object representation, because OrientDB ODatabaseObject is built on top of ODatabaseDocument

public class MyController extends Controller {
    static ODatabaseObjectTx db;

    public static void index() {
        OObjectIteratorMultiCluster<Account> accounts = db.browseClass(Account.class);


Graph Database

A simple test:

public class MyController extends Controller {
   @Inject static OGraphDatabase database;
   public static void someMethod() {
      OClass vehicleClass = database.createVertexType("GraphVehicle");
      database.createVertexType("GraphCar", vehicleClass);
      database.createVertexType("GraphMotocycle", "GraphVehicle");

      ODocument carNode = (ODocument) database.createVertex("GraphCar").field("brand", "Hyundai")
                    .field("model", "Coupe").field("year", 2003).save();
      ODocument motoNode = (ODocument) database.createVertex("GraphMotocycle").field("brand", "Yamaha")
                    .field("model", "X-City 250").field("year", 2009).save();

      database.createEdge(carNode, motoNode).save();

Direct access

If you need direct access to any ODatabase use play.modules.orientdb.ODB

ODatabaseDocumentTx docdb = ODB.openDocumentDB();

and so on

Hooks and Listeners

To register RecordHooks or DatabaseListeners, implement the proper interface (ORecordHook or ODatabaseListener) and put the code under /app, the module will find and register these classes at startup.