<@U319ZJ3B4> , this is a quick replacement for spr...
# exposed
j
@sss , this is a quick replacement for spring's `@Transactional`:
Copy code
transaction { em ->
            em.persist(Order(description = "Testing"))
        }
And the code for that transaction block:
Copy code
inline fun transaction(f: (em: EntityManager) -> Unit) {
    val em = EMF.createEntityManager()
    try {
        em.transaction.begin()
        f(em)
        em.transaction.commit()
    } catch (e: Exception){
        log.error(e.message, e)
        em.transaction.rollback()
    } finally {
        em.close()
    }
}