Search in sources :

Example 6 with UserDbo

use of webpiecesxxxxxpackage.db.UserDbo in project webpieces by deanhiller.

the class CrudUserController method postDeleteUser.

public Redirect postDeleteUser(int id) {
    UserDbo ref = Em.get().find(UserDbo.class, id);
    List<UserRole> roles = ref.getRoles();
    for (UserRole r : roles) {
        Em.get().remove(r);
    }
    Em.get().remove(ref);
    Em.get().flush();
    Current.flash().setMessage("User deleted");
    Current.flash().keep(true);
    Current.validation().keep(false);
    return Actions.redirect(CrudUserRouteId.LIST_USERS);
}
Also used : UserDbo(webpiecesxxxxxpackage.db.UserDbo) UserRole(webpiecesxxxxxpackage.db.UserRole)

Aggregations

UserDbo (webpiecesxxxxxpackage.db.UserDbo)6 EntityManager (javax.persistence.EntityManager)4 UserRole (webpiecesxxxxxpackage.db.UserRole)4 Query (javax.persistence.Query)3 UseQuery (org.webpieces.plugin.hibernate.UseQuery)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Singleton (javax.inject.Singleton)1 EntityTransaction (javax.persistence.EntityTransaction)1 NotBlank (javax.validation.constraints.NotBlank)1 Size (javax.validation.constraints.Size)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Current (org.webpieces.ctx.api.Current)1 Em (org.webpieces.plugin.hibernate.Em)1 Action (org.webpieces.router.api.controller.actions.Action)1 Actions (org.webpieces.router.api.controller.actions.Actions)1 FlashAndRedirect (org.webpieces.router.api.controller.actions.FlashAndRedirect)1 Redirect (org.webpieces.router.api.controller.actions.Redirect)1 Render (org.webpieces.router.api.controller.actions.Render)1