use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class HibernateAsyncController method runEntityLoad.
private Render runEntityLoad(EntityManager mgr, Integer id) {
UserTestDbo user = mgr.find(UserTestDbo.class, id);
log.info("user loaded");
return Actions.renderThis("user", user);
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class TestSyncHibernate method verifyLazyLoad.
public static void verifyLazyLoad(int id) {
//verify lazy load is working so we know test is testing what it should be
EntityManagerFactory factory = Persistence.createEntityManagerFactory(HibernateAppMeta.PERSISTENCE_TEST_UNIT);
EntityManager mgr = factory.createEntityManager();
EntityTransaction tx = mgr.getTransaction();
tx.begin();
UserTestDbo user = mgr.find(UserTestDbo.class, id);
UserTestDbo manager = user.getManager();
Assert.assertEquals("somadsf", manager.getName());
mgr.flush();
tx.commit();
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class TestSyncHibernate method testHibernatePostPartialDataDoesntBlowDataAway.
@Test
public void testHibernatePostPartialDataDoesntBlowDataAway() {
UserTestDbo user = loadDataInDb();
HttpDummyRequest req = Requests.createPostRequest("/testmerge", "user.id", user.getId() + "", "user.name", "blah1", "user.firstName", "blah2");
http11Socket.send(req);
FullResponse response = ResponseExtract.assertSingleResponse(http11Socket);
response.assertStatusCode(KnownStatusCode.HTTP_303_SEEOTHER);
UserTestDbo user2 = load(user.getId());
//name changed
Assert.assertEquals("blah1", user2.getName());
//firstname changed
Assert.assertEquals("blah2", user2.getFirstName());
//lastname remained the same
Assert.assertEquals(user.getLastName(), user2.getLastName());
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class HibernateController method save.
/**
* 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 save() {
EntityManager mgr = Em.get();
UserTestDbo user = new UserTestDbo();
user.setEmail("dean@sync.xsoftware.biz");
user.setName("SomeName");
mgr.persist(user);
mgr.flush();
return Actions.redirect(HibernateRouteId.DISPLAY_ENTITY, "id", user.getId());
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class HibernateController method display.
public Render display(Integer id) {
EntityManager mgr = Em.get();
UserTestDbo user = mgr.find(UserTestDbo.class, id);
return Actions.renderThis("user", user);
}
Aggregations