Class EbeanModule

java.lang.Object
io.jooby.ebean.EbeanModule
All Implemented Interfaces:
Extension

public class EbeanModule extends Object implements Extension
Persistence module using Ebean: https://ebean.io.

 {
    install(new HikariModule());

    install(new EbeanModule());

    get("/", ctx -> {

      Database db = require(Database.class);
      ...
    });
 }
 
We do recommend the use of Hikari as connection pool, so make sure the hikari module is in your project dependencies.

Ebean depends on an annotation processor to do byte code enhancements. Please check https://ebean.io/docs/getting-started/maven for maven setup and https://ebean.io/docs/getting-started/gradle for gradle setup.

The module integrates Ebean with Jooby application properties and service registry (require calls or DI framework).

Properties

Module checks for `ebean.[name]` and `ebean.*` properties (in that order) and creates a DatabaseConfig. Check create(Jooby, String).

Since:
2.6.1
Author:
edgar
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new ebean module using the default name: db.
    EbeanModule(io.ebean.config.DatabaseConfig config)
    Creates a module using the provided database configuration.
    Creates a new ebean module.
  • Method Summary

    Modifier and Type
    Method
    Description
    static io.ebean.config.DatabaseConfig
    create(Jooby application, String name)
    Creates a new/default database configuration object from application configuration properties.
    void
    install(Jooby application)
     

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.jooby.Extension

    lateinit
  • Constructor Details

    • EbeanModule

      public EbeanModule(@NonNull String name)
      Creates a new ebean module.
      Parameters:
      name - Ebean name.
    • EbeanModule

      public EbeanModule()
      Creates a new ebean module using the default name: db.
    • EbeanModule

      public EbeanModule(@NonNull io.ebean.config.DatabaseConfig config)
      Creates a module using the provided database configuration.
      Parameters:
      config - Database configuration.
  • Method Details

    • install

      public void install(@NonNull Jooby application) throws Exception
      Specified by:
      install in interface Extension
      Throws:
      Exception
    • create

      @NonNull public static io.ebean.config.DatabaseConfig create(@NonNull Jooby application, @NonNull String name)
      Creates a new/default database configuration object from application configuration properties. This method look for ebean properties at:

      - ebean.[name] - ebean

      At look at ebean[.name] and fallbacks to [ebean].

      Parameters:
      application - Application.
      name - Ebean name.
      Returns:
      Database configuration.