Last updated Apr 4, 2024

Creating an EntityManager

The EntityManager is the corner stone of Active Objects.

The simplest way to create and configure an entity manager is by using the net.java.ao.builder.EntityManagerBuilder:

1
2
EntityManager entityManager = EntityManagerBuilder
                .url(jdbcProperties.url) // the JDBC url for database connection
                .username(jdbcProperties.username) 
                .password(jdbcProperties.passord)
                .auto() // configuring the connection pool, auto detects connection pools on the classpath
                .useWeakCache() // an option to use weak caches
                .build(); // actually builds the entity manager

That's all there is to it.

This example is obviously extracted from the the dog food blog.

When in an Atlassian plugin

There is no need for you to create your own entity manager, this is handled by the Active Objects plugin.

Rate this page: