public class TransactionalRequest extends Object implements Route.Decorator
Session and EntityManager to the current request
via SessionRequest.
The route pipeline runs inside a transaction which is commit on success or rollback in case of
exception.
Applies the SessionRequest decorator, so there is no need to use session request in
addition to transactional request.
Usage:
{
install(new HikariModule());
install(new HibernateModule());
decorator(new TransactionalRequest());
get("/handle", ctx -> {
EntityManager handle = require(EntityManager.class);
// work with handle.
});
}
| Constructor and Description |
|---|
TransactionalRequest()
Creates a new transactional request and attach to the default/first session factory registered.
|
TransactionalRequest(SessionRequest sessionRequest)
Creates a new transactional request.
|
TransactionalRequest(String name)
Creates a new transactional request and attach the to a named session factory.
|
| Modifier and Type | Method and Description |
|---|---|
Route.Handler |
apply(Route.Handler next) |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitthen, thensetRoutepublic TransactionalRequest(@Nonnull String name)
name - Name of the session factory.public TransactionalRequest()
public TransactionalRequest(@Nonnull SessionRequest sessionRequest)
sessionRequest - Session request instance.@Nonnull public Route.Handler apply(@Nonnull Route.Handler next)
apply in interface Route.DecoratorCopyright © 2020. All rights reserved.