Session session = HibernateUtil.getSessionFactory().openSession();
PlayerHibernateDAO myDAO = new PlayerHibernateDAO();
myDAO.setSession(session);
Transaction tx = session.beginTransaction();
Player myCustomer = myDAO.getPlayerByName(newCustomer);
tx.commit();
if (myCustomer == null) {
myHandler.debugInfo("New player: "+newCustomer);
tx = session.beginTransaction();
myCustomer = new Player();
myCustomer.setName(newCustomer);
session.save(myCustomer);
tx.commit();
myHandler.debugInfo(".. added to the database with id: "+myCustomer.getId());
}
tx = session.beginTransaction();
activeSession = new MerchantSession();
activeSession.setCustomer(myCustomer);
session.save(activeSession);