BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Speedment Releases Stream ORM Version 3.0.1

Speedment Releases Stream ORM Version 3.0.1

This item in japanese

Bookmarks

Speedment released version 3.0.1 (codename “Forest”) of their stream-based object-relational mapping (ORM) Java toolkit and runtime application. First introduced in June 2015, Speedment, a portmanteau blend of “speed” and “development,” promises to accelerate database programming by eliminating complex ORMs, and abstracting the processes of configuring database connectivity and performing operations on the data. 

New features include:

  • JPA-Style Persistence
  • Declarative Java 8 stream API for database operations
  • Better code generation
    • Primitive type support
    • Improved logging
  • Improved user interface
    • Version check
    • Highlight potential issues
    • Better output console
    • Improved "reload" merging from the database
    • Settable package name per table
    • Mapping to primitive fields
  • New Maven goals: “clear” and “reload”

The open-source version of Speedment supports the following databases:

Support for commercial databases, such as Oracle, are available in Speedment’s enterprise edition.

Getting Started

The following command, using Maven and an existing MySQL database, initiates an application build with Speedment:

mvn archetype:generate -DgroupId=org.redlich.publications 
  -DartifactId=publications -DarchetypeArtifactId=speedment-archetype-mysql 
  -DarchetypeGroupId=com.speedment.archetypes -DinteractiveMode=false 
  -DarchetypeVersion=3.0.1 && cd publications && mvn speedment:tool

This will create the subfolder specified in -DartifactID, change directory to it, and launch the Speedment tool as shown below:

Once the database name has been entered, the “Connect” button connects to the MySQL database and imports the schema as shown below:

Once project information has been customized, the “Generate” button generates Java source code fo the database tables and a generic Main.java file is ready for editing to write declarative Java 8 stream code for database operations.

For PostgreSQL and MariaDB databases, substitute the following parameter, as appropriate, into the command-line:

-DarchetypeArtifactId=speedment-archetype-postgresql

-DarchetypeArtifactId=speedment-archetype-mariadb

The project is ready to compile and run even before adding any database operation code:

mvn compile && mvn exec:java -Dexec.mainClass="{package}.Main"

Speedment’s API Quick Start page provides Java 8 stream code examples for database operations such as initialization, persistence, updates, and joins. A complete sample project can be found on the GitHub repository.

Per-Åke Minborg, CTO at Speedment, spoke to InfoQ about this latest release of Speedment.

InfoQ: What is your role at Speedment?

Per- Åke Minborg: I am a co-founder and CTO of Speedment; in this role I lead the technical development and Speedment's community engagement around Java.

InfoQ: What sets Speedment apart from other Java ORM frameworks such as Hibernate, jOOQ, and Apache Torque?

Minborg: Speedment answers the question of how to seamlessly tie an existing relational database to modern Java 8 streams based applications. The Java developer expresses all the needed data operations in terms of declarative streams operations and the Speedment framework then determines which parts of the created data pipeline will be better handled by the database engine and what to leave for the JVM. Thus, the Java application code will handle complex data operations without using any query language. Any changes in the database data model will automatically be brought to the Java application since the interface to the database data is generated code, allowing the developer to use the compiler to find any emerging mismatch between database and application as the database model evolves over time. As elaborated more in-depth here: https://dzone.com/articles/declarative-programming-with-speedment-30 , the Java part of the application data handling can be declarative in a way that is unheard of before Speedment.

 

In contrast, the Java developer using Hibernate will need to use an extra language to communicate with the database since the queries to the database are expressed in HQL which is very similar to SQL. This means that if the database model evolves over time, any mismatches with the application code will be found in runtime. Thus using two languages is error prone and induces high maintenance costs. In addition, the language barrier between Java and HQL defeats the purpose of the declarative nature of the Java 8 functional programming paradigm allowed by streams. A longer elaboration of this conceptually important distinction is offered here: https://dzone.com/articles/streams-in-hibernate-and-beyond

 

Building on the Hibernate assumption that the Java developer needs to be exposed to the query language, jOOQ allows for a rather explicit building of actual SQL code from Java. While in many aspects more elegant than Hibernate to this end, it contrasts Speedment in the same way as Hibernate - the explicit focus on query language which Speedment abstracts away.

 

Apache Torque assumes that the data is modeled neither in Java nor in SQL, but in XML. This is a good fit for a project that starts out from scratch that needs persistence with little or no interest in the actual SQL data model that will be generated, but it does not allow any clean migration path for an existing relational database nor does it allow the user to leverage any database specific features since the data model is expressed outside of the database engine.

 

Another feature of abstracting the query language from the Java code is that without changing the Java application code, the Speedment framework can be configured to use some other data source, such as an in-JVM-memory data store. This is how Speedment Insane Mode works - since the data operation pipelines of the Speedment powered Java application describes only what to be done to the data, the Speedment framework is free to determine how that is done. This freedom can be used to completely alter the way data is retrieved without affecting the Java application logic. Nothing of this sort is possible for any of the other mentioned frameworks since applications building on a query language based framework will be unavoidably tied to that particular mode of data retrieval.

InfoQ: What advice can you provide for developers and organizations on when to invest in Speedment Enterprise?

Minborg: Speedment Open Source is for Open Source databases. For customers that have enterprise databases, like Oracle, an enterprise basic license with database connectors is needed. This license also includes service and support.

 

Moreover, with an enterprise advance license the customer gets the Speedment Insane Mode functionality which speeds up the application response times by orders of magnitude.

 

This license includes In-JVM Data technology and provides relief from performance bottlenecks.

InfoQ: What can you tell us about your partners and customers using Speedment?

Minborg: We have thousands of open source users around the globe. Speedment Enterprise is used in several sectors, including telecommunication, banking, insurance, energy and logistics. Partners and customers include Vaadin, Sencha, Higher Frequency Trading, and Extremely Heavy Industries.

InfoQ: What’s on the horizon for Speedment?

Minborg: We are looking into adding more features to our trial version to make the software available for developers in a test-environment for free. One part of this would be to make our In-JVM-Memory Insane Mode a part of the developer license.

 

We are going to add Spring Boot and Vaadin integration. We are also continuously adding connectors for more data sources. And of course we will support Java 9.

Rate this Article

Adoption
Style

BT