when u r using HQL, then use executeUpdate() on ur Query object.
if u r using Object based data insertion and deletion use save(),delete() and update() methods on session object.
for eg.,
if using HQL.
SessionFactory fact = new Configuration().configure().buildSessionFactory();
sess = fact.openSession();
Transaction tr = sess.beginTransaction();
sess.createQuery("delete from Hosts where hostId = " + new Integer(hid)).executeUpdate();
if Object based.,
Hosts h=new Hosts();
h.setName('Madan');
session.save(h); // insertion
// for deleting host object with id=41;
Hosts hd=(Hosts) session.find(Hosts.class,41);
session.delete(hd);
**) don't forget to commit ur transaction, then only session changes updated to DB.
_________________ If u feel it will help you, don't forget to rate me....
|