jeudi 11 juin 2015

Transaction management in Play Framework 1.3

As described here (relevant parts),

http://ift.tt/1Awq5MS

Transaction management

Play will automatically manage transactions for you. It will start a transaction for each HTTP request and commit it when the HTTP response is sent. If your code throws an exception, the transaction will automatically rollback.

If you need to force transaction rollback from the application code, you can use the JPA.setRollbackOnly() method, which tells JPA not to commit the current transaction.

You can also use annotations to specify how transactions should be handled.

If you annotated the method in the controller with @play.db.jpa.Transactional(readOnly=true), then the transaction will be read-only.

If you want to prevent Play from starting any transaction at all, you can annotate the method with @play.db.jpa.NoTransaction.

To prevent transactions for all methods, you can annotate the Controller-class with @play.db.jpa.NoTransaction.

When using @play.db.jpa.NoTransaction, Play does not get a connection from the connection pool at all – which improves speed.

I.e all transactions in Play 1.3 is a container-managed transactions, all actions automatically wrapped in transactions. What annotations provides Play 1.3 to manage transactions directly?

For example, if the method called from the client's transaction - client transaction is suspended and for the method creates a new transaction or method performed as part of the client's transaction?

I would be very grateful for the information. Thanks to all.

Aucun commentaire:

Enregistrer un commentaire