Object-Relational-Mapping via Ebean ORM. It configures and exports EbeanServer instances.
NOTE: This module depends on jdbc module.
EbeanServer
<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-ebean</artifactId>
<version>1.5.0</version>
</dependency>{
use(new Jdbc());
use(new Ebeanby().doWith((ServerConfig conf) -> {
conf.addClass(Pet.class);
}));
get("/pets", req -> {
EbeanServer ebean = require(EbeanServer.class);
return ebean.createQuery(Pet.class)
.findList();
});
}The enhancement process comes in two flavors:
-
Runtime: via a JVM Agent
-
Build time: via Maven plugin
The recommended setup consist of setting up both: runtime and build time enhancement.
The runtime enhancer increases developer productivity, it let you start your app from IDE
and/or mvn jooby:run. All you have to do is to add the agent dependencies to your
classpath:
<dependency>
<groupId>org.avaje.ebeanorm</groupId>
<artifactId>avaje-ebeanorm-agent</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.avaje</groupId>
<artifactId>avaje-agentloader</artifactId>
<scope>test</scope>
</dependency>Did you see the test scope? We don't want to use the runtime enhancer while
running in prod. Instead, we want to use the build time enhancer.
All you have to do is to add avaje-ebeanorm-mavenenhancer to your pom.xml as described
in the official doc.
Alternative, and because we want to keep our pom.xml small, you can drop a ebean.activator
file inside the src/etc folder. The presence of the file src/etc/ebean.activator
will trigger the avaje-ebeanorm-mavenenhancer plugin.
Configuration is done via .conf, for example:
ebean.ddl.generate=false
ebean.ddl.run=false
ebean.debug.sql=true
ebean.debug.lazyload=false
ebean.disableClasspathSearch = falseOr programmatically:
{
use(new Ebeanby().doWith(ebean -> {
ebean.setDisableClasspathSearch(false);
}));
}We do provide an ebean-starter project. Go and fork it.
That's all folks!!
These are the default properties for ebean:
ebean.defaultServer = true
ebean.register = true
ebean.ddl.generate=false
ebean.ddl.run=false
ebean.debug.sql=true
ebean.debug.lazyload=false
ebean.disableClasspathSearch = true
# -------------------------------------------------------------
# Transaction Logging
# -------------------------------------------------------------
# Use java util logging to log transaction details
ebean.loggingToJavaLogger=false
# General logging level: (none, explicit, all)
ebean.logging=all
# Sharing log files: (none, explicit, all)
ebean.logging.logfilesharing=all
# location of transaction logs
ebean.logging.directory=logs
# Specific Log levels (none, summary, binding, sql)
ebean.logging.iud=sql
ebean.logging.query=sql
ebean.logging.sqlquery=sql
ebean.logging.txnCommit=none