How to remove not one record, but every search-id 1 in the OBD system.
-
How do you do a method to remove not one, but every record with 1 in search_id
It's HibernateUril class and the method deletes one note.
public static void delete(String HQL){ Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); Query q = session.createQuery(HQL); DataEntity platform = (DataEntity) q.list().get(0); session.delete(platform); session.getTransaction().commit(); session.close(); }
Main
HibernateUtil.delete("from TenderEntity where search_id = " + searchEntity.getId());
-
Staying within this code:
Query q = session.createQuery(HQL); for(Object entity : q.list()) { DataEntity platform = (DataEntity) entity; session.delete(platform); } session.getTransaction().commit();
If interceptor-is not used, which should be given for the essence of the different stages of its life cycle (in this case prior to disposal), this may be done by one request to the OBD without a request for:
session.beginTransaction(); Query query = session.createQuery(HQL); query.executeUpdate(); session.getTransaction().commit(); session.close();
Only the client of this method will be required to a modified request:
HibernateUtil.delete("delete TenderEntity where search_id = " + searchEntity.getId());