use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class TestAjaxHibernate method loadDataInDb.
public static UserTestDbo loadDataInDb() {
String email = "dean2@sync.xsoftware.biz";
//populate database....
EntityManagerFactory factory = Persistence.createEntityManagerFactory(HibernateAppMeta.PERSISTENCE_TEST_UNIT);
EntityManager mgr = factory.createEntityManager();
EntityTransaction tx = mgr.getTransaction();
tx.begin();
UserTestDbo user = new UserTestDbo();
user.setEmail(email);
user.setName("SomeName");
user.setFirstName("Dean");
user.setLastName("Hill");
mgr.persist(user);
mgr.flush();
tx.commit();
return user;
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class CrudTestController method multiSelect.
public Render multiSelect(Integer id) {
if (id == null) {
return Actions.renderThis("entity", new UserTestDbo(), "levels", LevelEducation.values(), "roles", Role.values(), "selectedRoles", new ArrayList<>());
}
UserTestDbo user = UserTestDbo.findWithJoin(Em.get(), id);
List<UserRoleDbo> roles = user.getRoles();
List<Role> selectedRoles = roles.stream().map(r -> r.getRole()).collect(Collectors.toList());
return Actions.renderThis("entity", user, "levels", LevelEducation.values(), "roles", Role.values(), "selectedRoles", selectedRoles);
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class CrudTestController method userList.
public Render userList() {
EntityManager mgr = Em.get();
Query query = mgr.createNamedQuery("findAllUsers");
@SuppressWarnings("unchecked") List<UserTestDbo> users = query.getResultList();
return Actions.renderThis("users", users);
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class TestSyncHibernate method load.
private UserTestDbo load(Integer id) {
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);
tx.commit();
return user;
}
use of org.webpieces.plugins.hibernate.app.dbo.UserTestDbo in project webpieces by deanhiller.
the class TestSyncHibernate method loadDataInDb.
public static UserTestDbo loadDataInDb() {
String email = "dean2@sync.xsoftware.biz";
//populate database....
EntityManagerFactory factory = Persistence.createEntityManagerFactory(HibernateAppMeta.PERSISTENCE_TEST_UNIT);
EntityManager mgr = factory.createEntityManager();
EntityTransaction tx = mgr.getTransaction();
tx.begin();
UserTestDbo manager = new UserTestDbo();
manager.setEmail("asdf@asf.com");
manager.setName("somadsf");
UserTestDbo user = new UserTestDbo();
user.setEmail(email);
user.setName("SomeName");
user.setFirstName("Dean");
user.setLastName("Hill");
user.setManager(manager);
mgr.persist(manager);
mgr.persist(user);
mgr.flush();
tx.commit();
return user;
}
Aggregations