SAP Hana

Testing

To test using SAP Hana set the platform to hana in src/test/resources/application-test.yaml

Refer to docs / testing if application-test.yaml doesn't exist yet.

ebean:
  test:
    platform: hana # h2, postgres, mysql, oracle, sqlserver
    ddlMode: dropCreate # none | dropCreate | migrations
    dbName: test

The above will use the following defaults:

username:SYSTEM
password:HXEHana1
databaseName:HXE
port:39017
url:jdbc:sap://localhost:{port}/?databaseName={databaseName}
driver:com.sap.db.jdbc.Driver
image:store/saplabs/hanaexpress:{version}

ebean-hana dependency

We can use the io.ebean:ebean-hana dependency rather than io.ebean:ebean if we want to only bring in the Hana specific platform code. Depending on io.ebean:ebean will bring in all platforms.

Docker container

We can programmatically start a docker container version of Hana.

The below uses ebean-test-docker dependency which already comes with ebean-test. If we do not have a dependency on ebean-test then add io.ebean:ebean-test-docker:5.0 as a dependency.

package main;

import io.ebean.docker.commands.HanaContainer;

public class Main {

  public static void main(String[] args) {

    HanaContainer.Builder builder = HanaContainer.newBuilder("2.00.033.00.20180925.2");
    builder.port(39117);
    builder.instanceNumber("91");
    try {
      builder.passwordsUrl(new URL("file:///hana/mounts/" + this.passwordsFile.getFileName()));
    } catch (MalformedURLException e) {
      fail(e.getMessage());
    }
    builder.mountsDirectory(this.tempDir.toString());
    builder.agreeToSapLicense(false);

    HanaContainer container = builder.build();

    container.start();
  }
}