Follow to: ActiveJDBC documentation

5 minute introduction

For a simple example we will use a table called PEOPLE created with this MySQL DDL:

ActiveJDBC infers DB schema parameters from a database. This means you do not have to provide it in code.

The corresponding model looks like this:

There is no code in the body of the class, and yet it is fully functional and will map to a table called PEOPLE automatically. Read more on English Inflections.

How to query

Simplest query example:

The where() method takes a snippet of real SQL. The first line above will generate this statement: SELECT * FROM people WHERE first_name = 'John'.

Finder methods can also be parametrized:

The where() method takes a vararg, allowing unlimited any number of parameters to be passed into a statement.

Paging through data

This query will ensure that the returned result set will start at the 21st record and will return only 10 records, according to the orderBy. The ActiveJDBC has a built in facility for various database flavors and it will generate appropriate SQL statement that is specific for a DB (Oracle, MySQL, etc) and is efficient. It will not fetch all records, starting with 1.

Creating new records

There are several ways to do this, and the simplest is:

There is also a shorthand version of doing the same:

and yet shorter one :

Updating a record

Deleting a record

There are more ways to delete, follow Delete cascade to learn more.

Getting started

If you want to get started, follow these links:

Please, see Getting Started for a working example.

Look through these:

Other working examples:

Here is the JavaDoc

Design principles

  • Infers metadata from DB
  • Convention-based configuration.
  • No need to learn another QL. SQL is sufficient
  • Code often reads like English
  • No sessions, no attaching, re-attaching
  • No persistence managers.
  • Models are lightweight, simple POJOs
  • No proxy-ing. What you write is what you get (WYWIWYG :))
  • No getters and setters. You can still write them if you like.
  • No DAOs and DTOs
  • No Anemic Domain Model

Supported databases

Currently the following databases are supported:

  • SQLServer 2019
  • MariaDB (10.5.8)
  • Oracle (
  • PostgreSQL (13.1)
  • H2
  • SQLite3
  • DB2 (

The versions listed above are what we use for testing. There is no reason to think that ActiveJDBC does not support a different version, after all it is a pass-through framework.

Adding a new dialect is relatively easy. Just look at commits on this branch: h2integration


Please, refer to the Releases page.

Getting the latest version

For the latest version refer to ActiveJDBC on Maven Central. If you use Maven add this to your pom:

Do not forget to replace LATEST_VERSION with the latest version deployed to Maven Central (see above)

Additionally, configure Instrumentation plugin:

Or download from: ActiveJDBC Instrumentation plugin on Maven Central

Getting latest snapshot versions

If you are using Maven, add these repositories to your pom:

If you are not using Maven, you can pull down the latest snapshots from here: Sonatype Snapshots

How to comment

The comment section below is to discuss documentation on this page.

If you have an issue, or discover bug, please follow instructions on the Support page