Skip to Content

What is Ebean ORM?

Ebean ORM is an object-relational mapping (ORM) framework for Java and Kotlin. The framework can be used to map Java objects from an object-oriented domain model to relational database tables. The framework’s feature set also comprises query and retrieval capabilities which automatically translate between object-oriented Java code and relational SQL queries.

Ebean ORM is, for example, included with the Play Framework to simplify the database access.

What’s new?

Until now there was no support for SAP HANA included in the Ebean ORM framework. Starting with release 11.23.1 there are now Ebean platforms for the SAP HANA column and row stores available.The platforms implement the full range of functions provided by SAP HANA including database-generated identity columns, sequences, table and column comments, and more.

How can I get started?

To get started you can follow the Ebean Getting Started tutorial.

In addition to the Ebean dependencies, you’ll need to add the HANA JDBC driver to your dependency management descriptor (pom.xml if you’re using Maven).

<dependency>
  <groupId>com.sap.cloud.db.jdbc</groupId>
  <artifactId>ngdbc</artifactId>
  <version>2.3.48</version>
</dependency>

Automatic database setup via Docker image

If you’re developing on Linux, Ebean (via the ebean-test-config module) can automatically start a test instance of HANA, express edition inside a docker container.

The HANA support in ebean-test-config is available from version 11.27.2. Make sure to include at least this version as a dependency.

For the automatic database setup to work, you’ll have to create a directory on your local machine that the HANA Docker image can use to store its data.

sudo mkdir -p /example/directory
sudo chown 12000:79 /example/directory

Inside this newly created directory you’ll have to add a JSON file named, for example, passwords.json, containing default passwords for the database instance.

{
   "master_password" : "HXEHana1"
}

Once you’ve done this, you can adjust the Ebean test configuration (application-test.yml) as follows:

ebean:
  test:
#    shutdown: stop # stop | remove
    platform: hana
    ddlMode: dropCreate # none | dropCreate | create | migration | createOnly | migrationDropCreate
    dbName: myapp
    hana:
        version: 2.00.033.00.20180925.2
        mountsDirectory: /example/directory
        passwordsUrl: file:///hana/mounts/passwords.json
        agreeToSapLicense: true  # indicate that you agree to the SAP HANA, express edition license (https://www.sap.com/docs/download/cmp/2016/06/sap-hana-express-dev-agmt-and-exhibit.pdf)
        # instanceNumber: 90 # set this if you want to use a different instance number, for example, if you're running multiple instances of HANA

Running your tests now will automatically setup a Docker container running an instance of SAP HANA, express edition, and execute your tests against this database instance.

Manual database setup

If you can’t or don’t want to use the Ebean Docker image mechanism, you can also set up your SAP HANA, express edition database manually.

There are several options to run HANA:

Once you have set up your HANA instance, you can configure Ebean to connect to the database. Create a file named application-test.properties with the following content

ebean.ddl.generate=true
ebean.ddl.run=true
ebean.migration.appName=myapp
datasource.default=hana
datasource.hana.username=EBEAN_TEST
datasource.hana.password=Eb3an_test
datasource.hana.databaseUrl=jdbc:sap://hxehost:39013/?databaseName=HXE
datasource.hana.databaseDriver=com.sap.db.jdbc.Driver

This configuration assumes that you have a HANA instance running on port 39013 (SYSTEMDB of instance 90) with a tenant database named “HXE” containing a user “EBEAN_TEST” with password “Eb3an_test”.

If this configuration doesn’t match your set up, make sure to adjust it appropriately before running the tests.


Happy coding!

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply