Speedment is a completely self-contained runtime with no external transitive dependencies. This is important because it allows you to avoid potential version conflicts with other libraries and the ever lurking “Jar Hell”. Furthermore, there is a “deploy” variant available where all Speedment runtime modules have been packed together into a single compound JAR.

Spring Boot

It is easy to integrate any Speedment project with Spring Boot. Here is an example of a Speedment Configuration file for Spring:

public class AppConfig {
    private @Value("${dbms.username}") String username;
    private @Value("${dbms.password}") String password;
    private @Value("${dbms.schema}") String schema;

    public SakilaApplication getSakilaApplication() {
        return new SakilaApplicationBuilder()

    // Individual managers
    public FilmManager getFilmManager(
         SakilaApplication app
    ) {
        return app.getOrThrow(FilmManager.class);

So, when you need to use a Manager in a Spring MVC Controller, you can now simply auto-wire it:

private @Autowired FilmManager films;

There is a specific Spring Boot plugin that you can add to your Speedment Maven-plugin if you use Speedment Stream or HyperStream.

Java EE

Integrating Speedment with Java EE can be done effortlessly. Here is an example of a Singleton Bean for Java EE and Speedment:

public class AppBean {
  private SakilaApplication app;

  void init {
      app = new SakilaApplicationBuilder()

  public FilmManager getFilmManager() {
      return app.getOrThrow(FilmManager.class);


Speedment gets its database connections using the DriverManager. Sometimes the Java EE server needs to be setup to work efficiently for such connecions. A guide on how to setup a JDBC connection in GlassFish is available here.

Read more on Java EE and Speedment in the original Speedment Wiki here.


Writing web applications and REST endpoints using, for example, Spring Boot or Java EE is an easy task. Speedment is a perfect match for providing data to such applications.

In this example, the assignment is to write a method serveFilms(String rating, int page) that returns a stream of Film entities. The rating controls the stream, allowing only films with the given rating to appear in the stream. If rating is null, then all films will be returned. Furthermore, the page parameter indicates which page to be rendered on the web user’s screen. The first page is page 0, the next is 1 et cetera. Finally, all films shall be ordered by length.

This can be done like this:

private static final int PAGE_SIZE = 50;
private Stream<Film> serveFilms(
      String rating, int page
    ) {
     Stream<Film> stream =;
    if (rating != null) {
        stream = stream.filter(Film.RATING.equal(rating));
    return stream
        .skip(page * PAGE_SIZE)

The code snippet above could easily be improved to take parameters specifying a dynamic sort order and a custom page size.


Often when you write database applications you will need to send different output to a client app. There are many protocols for sending results over a network. One of the most common is JSON.

A number of third party JSON libraries can be used in conjunction with Speeedment including GSON. Speedment can also handle JSON output using the Speedment JSON plugin.

This is how you add the Speedment JSON plugin to your project:


Once the plugin is added, you gain access to a number of additional methods related to JSON handling.

A more advanced JSON Plugin is available for Speedment Stream and HyperStream. Read more about it here.


If you have a database where String columns are stored as a limited number of distinct values (i.e. has low cardinality), consider using the Speedment Enum plugin. It will enable mapping of String columns to java enums, allowing more efficient use of memory and increased type safety.

This is how you add the Speedment Enum plugin to your project:


When the plugin has been configured, you gain access to additional methods related to Enum handling.

Define an Enum - Select a Column
Options for Enums are enabled in the Speedment Tool

A more advanced Enum Plugin is available in Speedment Enterprise. Read more about that here.

Questions and Discussion

If you have any question, don’t hesitate to reach out to the Speedment developers on Gitter.