List of usage examples for org.hibernate Session delete
void delete(Object object);
From source file:bank.DAO.BillDAO.java
public void deleteEntity(Object o) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from www. j a v a2s . com*/ session.delete(o); session.flush(); session.getTransaction().commit(); }
From source file:bank.DAO.CardDAO.java
public void deleteCards(List<Card> result) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();/*from w w w . j a va 2 s . c om*/ for (Card p : result) { System.out.println("Delete:" + p.getNumber() + ":" + p.getStart_date()); session.delete(p); //session.flush(); } session.createSQLQuery("delete from card where number = 1").executeUpdate(); session.getTransaction().commit(); }
From source file:bank.DAO.ClientsDAO.java
public void deleteClients(List<Clients> result) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();// w w w.ja v a2 s.c o m for (Clients p : result) { System.out.println("Delete:" + p.getId() + ":" + p.getPassport_No()); session.delete(p); //session.flush(); } //session.createSQLQuery("delete from clients where id = 1").executeUpdate(); session.getTransaction().commit(); }
From source file:basedistribuida.connection.HibernateSession.java
protected boolean delete(Object clazz) { Session session = sessionFactory.openSession(); try {//from w w w . j a v a2 s. c om session.beginTransaction(); session.delete(clazz); session.getTransaction().commit(); } finally { session.close(); } return true; }
From source file:baza.Broker.java
public boolean obrisiPacijenta(Pacijent p) { boolean uspesno = false; Session session = Test.getSessionFactory().openSession(); try {/*from w ww . j a v a 2 s . com*/ session.beginTransaction(); session.delete(p); session.getTransaction().commit(); uspesno = true; } catch (HibernateException hibernateException) { session.getTransaction().rollback(); } finally { session.close(); } return uspesno; }
From source file:baza.Broker.java
public boolean obrisiPregled(Pregled p) { boolean uspesno = false; Session session = Test.getSessionFactory().openSession(); try {/*from w w w. j av a 2 s.c o m*/ session.beginTransaction(); session.delete(p); session.getTransaction().commit(); uspesno = true; } catch (Exception e) { session.getTransaction().rollback(); } finally { session.close(); } return uspesno; }
From source file:bazydanych.CRUDTest.java
public void deleteCar(Integer ID) { Session session = factory.openSession(); Transaction tx = null;/*from w ww . j ava 2 s . c om*/ try { tx = session.beginTransaction(); Samochod car = (Samochod) session.get(Samochod.class, ID); session.delete(car); tx.commit(); } catch (HibernateException e) { if (tx != null) tx.rollback(); e.printStackTrace(); } finally { session.close(); } }
From source file:bazydanych.KsiazkiTest.java
private void deleteBook(Integer bookId) { Session session = factory.openSession(); Transaction tx = null;//from w ww.ja va 2 s . c o m try { tx = session.beginTransaction(); Ksiazka book = (Ksiazka) session.get(Ksiazka.class, bookId); session.delete(book); tx.commit(); } catch (HibernateException e) { if (tx != null) { tx.rollback(); } e.printStackTrace(); fail(); } finally { session.close(); } }
From source file:bazydanych.ManageEmployee.java
public void deleteEmployee(Integer EmployeeID) { Session session = factory.openSession(); Transaction tx = null;//from w w w. ja v a 2 s .c om try { tx = session.beginTransaction(); Employee employee = (Employee) session.get(Employee.class, EmployeeID); session.delete(employee); tx.commit(); } catch (HibernateException e) { if (tx != null) tx.rollback(); e.printStackTrace(); } finally { session.close(); } }
From source file:bazydanych.OneToManyTest.java
private void deleteEmployee(Integer EmployeeID) { Session session = factory.openSession(); Transaction tx = null;//from w w w . j a v a 2s .c om try { tx = session.beginTransaction(); Employee employee = (Employee) session.get(Employee.class, EmployeeID); session.delete(employee); tx.commit(); } catch (HibernateException e) { if (tx != null) { tx.rollback(); } e.printStackTrace(); fail(); } finally { session.close(); } }