List of usage examples for org.hibernate Session flush
void flush() throws HibernateException;
From source file:com.booleanworks.kryptopterus.application.MainHibernateUtil.java
License:Apache License
public Object delete(Object object, Session session) { System.out.println("com.booleanworks.kryptopterus.application.MainHibernateUtil.delete()"); System.out.println("session => " + session.hashCode()); Object result = null;//from w w w . ja v a 2 s. co m if (session == null || !session.isConnected() || !session.isOpen()) { session = this.getResidentSession(); } if (session.isJoinedToTransaction()) { session.delete(object); if (!(session.getTransaction().getStatus() == TransactionStatus.MARKED_ROLLBACK)) { session.flush(); } //session.detach(object) ; result = object; } else { Transaction transaction = this.beginTransaction(session, false); session.delete(object); session.flush(); //session.detach(object) ; result = object; this.commitTransaction(session, transaction); } return result; }
From source file:com.booleanworks.kryptopterus.entities.AppActivityRelation.java
License:Apache License
@Deprecated public void link(AppActivity first, AppActivity second) { Session session = MainHibernateUtil.getInstance().getNewSession(FlushMode.ALWAYS, CacheMode.IGNORE); this.link(first, second, session); session.flush(); session.close();/*from ww w . j a va 2s. c om*/ }
From source file:com.br.uepb.dao.MedicaoBalancaDAO.java
License:Open Source License
/** * Metodo para excluir a medio da balana * @param medicao Objeto de representao da medio da balana(MedicaoBalancaDomain) *///from w w w .j av a 2 s .co m public void excluiMedicaoBalanca(MedicaoBalancaDomain medicao) { Session novaSessao = SessaoAtual(); Transaction tx = SessaoAtual().beginTransaction(); novaSessao.delete(medicao); novaSessao.flush(); tx.commit(); }
From source file:com.br.uepb.dao.MedicaoBalancaDAO.java
License:Open Source License
/** * para excluir a medio da balana de acordo com o id do paciente * @param idPaciente Id do Paciente/*from w ww . ja v a 2 s. c om*/ * @return Retorna true se conseguir excluir a medicao e false caso contrrio */ public Boolean excuiMedicaoBalancaPorPaciente(int idPaciente) { try { Session novaSessao = SessaoAtual(); Transaction tx = SessaoAtual().beginTransaction(); novaSessao.createQuery("delete from MedicaoBalancaDomain where paciente.id = :id") .setParameter("id", idPaciente).executeUpdate(); novaSessao.flush(); tx.commit(); return true; } catch (Exception e) { return false; } }
From source file:com.br.uepb.dao.MedicaoOximetroDAO.java
License:Open Source License
/** * Mtodo para exlcuir a medio do oximetro * @param medicao Objeto de representao da medio do Oxmetro(MedicaoOximetroDomain) * @return Boolean - Retorna true se conseguir excluir a medio e false caso contrrio *///from w w w . java2s. c o m public Boolean excluiMedicaoOximetro(MedicaoOximetroDomain medicao) { try { Session novaSessao = SessaoAtual(); Transaction tx = SessaoAtual().beginTransaction(); novaSessao.delete(medicao); novaSessao.flush(); tx.commit(); return true; } catch (Exception e) { return false; } }
From source file:com.br.uepb.dao.MedicaoOximetroDAO.java
License:Open Source License
/** * para excluir a medio do oximetro de acordo com o id do paciente * @param idPaciente Id do Paciente/*w ww .j a v a 2s . co m*/ * @return Retorna true se conseguir excluir a medicao e false caso contrrio */ public Boolean excuiMedicaoOximetroPorPaciente(int idPaciente) { try { Session novaSessao = SessaoAtual(); Transaction tx = SessaoAtual().beginTransaction(); novaSessao.createQuery("delete from MedicaoOximetroDomain where paciente.id = :id") .setParameter("id", idPaciente).executeUpdate(); novaSessao.flush(); tx.commit(); return true; } catch (Exception e) { return false; } }
From source file:com.br.uepb.dao.MedicaoPressaoDAO.java
License:Open Source License
/** * Mtodo para excluir a medio da presso arterial * @param medicao Objeto de representao da medio da presso arterial(MedicaoPressaoDomain) *///from ww w . j av a 2s . co m public void excluiMedicaoPressao(MedicaoPressaoDomain medicao) { Session novaSessao = SessaoAtual(); Transaction tx = SessaoAtual().beginTransaction(); novaSessao.delete(medicao); novaSessao.flush(); tx.commit(); }
From source file:com.br.uepb.dao.MedicaoPressaoDAO.java
License:Open Source License
/** * para excluir a medio da presso de acordo com o id do paciente * @param idPaciente Id do Paciente//from w ww. j a va 2s. c o m * @return Retorna true se conseguir excluir a medicao e false caso contrrio */ public Boolean excuiMedicaoPressaoPorPaciente(int idPaciente) { try { Session novaSessao = SessaoAtual(); Transaction tx = SessaoAtual().beginTransaction(); novaSessao.createQuery("delete from MedicaoPressaoDomain where paciente.id = :id") .setParameter("id", idPaciente).executeUpdate(); novaSessao.flush(); tx.commit(); return true; } catch (Exception e) { return false; } }
From source file:com.br.uepb.dao.PacienteDAO.java
License:Open Source License
/** * Metodo para excluir o paciente//from w w w . ja va2 s .co m * @param paciente Objeto de representao do paciente(PacienteDomain) */ public void excluiPaciente(PacienteDomain paciente) { Session novaSessao = SessaoAtual(); LoginDAO loginDAO = new LoginDAO(); MedicaoOximetroDAO medicaoOxDAO = new MedicaoOximetroDAO(); MedicaoPressaoDAO medicaoPres = new MedicaoPressaoDAO(); MedicaoBalancaDAO medicaoB = new MedicaoBalancaDAO(); MedicaoIcgDAO medicaoI = new MedicaoIcgDAO(); LoginDomain login = loginDAO.obtemLoginPorPaciente(paciente.getId()); if (login != null) { deletaLogin(login); } Transaction tx = SessaoAtual().beginTransaction(); for (MedicaoOximetroDomain medicao : medicaoOxDAO.listaMedicoesDoPaciente(paciente.getId())) { novaSessao.delete(medicao); } for (MedicaoPressaoDomain medicao : medicaoPres.listaMedicoesDoPaciente(paciente.getId())) { novaSessao.delete(medicao); } for (MedicaoBalancaDomain medicao : medicaoB.listaMedicoesDoPaciente(paciente.getId())) { novaSessao.delete(medicao); } for (MedicaoIcgDomain medicao : medicaoI.listaMedicoesDoPaciente(paciente.getId())) { novaSessao.delete(medicao); } novaSessao.delete(paciente); novaSessao.flush(); tx.commit(); }