Elvis Oliveira
Elvis Oliveira

Reputation: 949

Get JPA Transaction outside Controllers - Play Framework

I'm using play 1.2.7 on my work. I'm trying to save an entity on database outside a Controller. I start a separated thread and in this thread in want to save some the entity.

It's possible with play to do this? How can I create a new Transaction?

Thanks!

Upvotes: 0

Views: 383

Answers (1)

gpgekko
gpgekko

Reputation: 3626

You should be able to initialize a JPA context and start a transaction by using JPAPlugin.startTx(boolean readonly);. Remember to manually close the transaction afterwards with JPAPlugin.closeTx(boolean rollback).

Upvotes: 2

Related Questions