0

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:

  • spring-boot-starter-data-jpa
  • Objectdb (embedded)
  • Maven
  • Uses annotation based configuration (no xml file)
  • A dummy entity class (e.g: Customer(id,firstname) )
  • A JpaRepository class or dao class with list() and @Transactional persist(Customer) methods

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

Abdullah Arslan
  • 271
  • 1
  • 3
  • 5

1 Answers1

1

ObjectDB support answered my question

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

Abdullah Arslan
  • 271
  • 1
  • 3
  • 5