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:

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.

Was this page helpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport