Search in sources :

Example 6 with UserTestDbo

use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.

the class HibernateAsyncController method runSave.

public Redirect runSave(EntityManager mgr) {
    UserTestDbo user = new UserTestDbo();
    user.setEmail("dean@async.xsoftware.biz");
    user.setName("SomeName");
    mgr.persist(user);
    mgr.flush();
    return Actions.redirect(HibernateRouteId.ASYNC_DISPLAY_ENTITY, "id", user.getId());
}
Also used : UserTestDbo(org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)

Example 7 with UserTestDbo

use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.

the class HibernateController method saveThenFail.

/**
	 * BIG NOTE: This is NOT the way you should use hibernate but is a base case for us to 
	 * just test out hibernate without filters and added complexity
	 * @return
	 */
public Redirect saveThenFail() {
    EntityManager mgr = Em.get();
    UserTestDbo user = new UserTestDbo();
    user.setEmail("dean2222@sync.xsoftware.biz");
    user.setName("SomeName");
    mgr.persist(user);
    mgr.flush();
    svc.fail(user.getId());
    return Actions.redirect(HibernateRouteId.DISPLAY_ENTITY, "id", user.getId());
}
Also used : EntityManager(javax.persistence.EntityManager) UserTestDbo(org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)

Example 8 with UserTestDbo

use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.

the class HibernateController method entityLoad.

public Render entityLoad(Integer id) {
    EntityManager mgr = Em.get();
    UserTestDbo user = mgr.find(UserTestDbo.class, id);
    log.info("loaded user");
    return Actions.renderThis("user", user);
}
Also used : EntityManager(javax.persistence.EntityManager) UserTestDbo(org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)

Example 9 with UserTestDbo

use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.

the class AjaxCrudTestController method postDeleteUser.

public Redirect postDeleteUser(int id) {
    UserTestDbo ref = Em.get().getReference(UserTestDbo.class, id);
    Em.get().remove(ref);
    Em.get().flush();
    Current.flash().setMessage("User deleted");
    Current.flash().keep();
    return Actions.redirect(AjaxCrudTestRouteId.AJAX_LIST_USERS);
}
Also used : UserTestDbo(org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)

Example 10 with UserTestDbo

use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.

the class AjaxCrudTestController method userList.

public Action userList() {
    EntityManager mgr = Em.get();
    Query query = mgr.createNamedQuery("findAllUsers");
    @SuppressWarnings("unchecked") List<UserTestDbo> users = query.getResultList();
    boolean showEditPopup = Current.flash().isShowEditPopup();
    return Actions.renderThis("users", users, "showPopup", showEditPopup);
}
Also used : EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) UserTestDbo(org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)

Aggregations

UserTestDbo (org.webpieces.plugins.hibernate.app.dbo.UserTestDbo)20 EntityManager (javax.persistence.EntityManager)13 EntityManagerFactory (javax.persistence.EntityManagerFactory)6 EntityTransaction (javax.persistence.EntityTransaction)6 Query (javax.persistence.Query)3 Test (org.junit.Test)3 WebserverForTest (org.webpieces.webserver.WebserverForTest)3 AbstractWebpiecesTest (org.webpieces.webserver.test.AbstractWebpiecesTest)3 FullResponse (org.webpieces.webserver.test.FullResponse)3 HttpDummyRequest (org.webpieces.webserver.test.HttpDummyRequest)3 UserRoleDbo (org.webpieces.plugins.hibernate.app.dbo.UserRoleDbo)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Singleton (javax.inject.Singleton)1 Current (org.webpieces.ctx.api.Current)1 Em (org.webpieces.plugins.hibernate.Em)1 ADD_USER_PAGE (org.webpieces.plugins.hibernate.app.HibernateRouteId.ADD_USER_PAGE)1 EDIT_USER_PAGE (org.webpieces.plugins.hibernate.app.HibernateRouteId.EDIT_USER_PAGE)1 LevelEducation (org.webpieces.plugins.hibernate.app.dbo.LevelEducation)1