Abdullah Arslan
Abdullah Arslan

Reputation: 421

How to use ObjectDB properly in spring boot application?

I have a spring boot application with objectdb embedded database.

I am manually handling connection and transaction operations as described at http://www.objectdb.com/java/jpa/persistence/overview

Below is a sample code that I am using: (taken from objecdb documentation): EntityManagerFactory emf = Persistence.createEntityManagerFactory("myDbFile.odb"); EntityManager em = emf.createEntityManager(); try { em.getTransaction().begin(); // Operations that modify the database should come here. em.getTransaction().commit(); } finally { if (em.getTransaction().isActive()) em.getTransaction().rollback(); }

It works but the code has become uggly since I had to use try catch finally blocks in order to properly close connections.

I want to refactore my application so that database operations are done in JpaRepositories or Dao classes with @Transactional methods (as described in http://spring.io/guides/gs/accessing-data-jpa/)

I had a research on the web but could not find any solution that works.

What I am looking for is a very simple spring boot sample application with:

Note: I already tried this post but could not make it work.

Upvotes: 1

Views: 837

Answers (1)

Abdullah Arslan
Abdullah Arslan

Reputation: 421

ObjectDB support answered my question

https://www.objectdb.com/forum/2328#item-6

Upvotes: 2

Related Questions