java - Hibernate: Object deleted but still can be loaded by Hibernate -


it seems absurd how after deleted object can load , print id. here's class use retrieve data prof entity :

public class profcrud { sessionfactory sessionfactory = hibernateutil.getsessionfactory(); session session ;    public arraylist<object> findprofbyprofid( int id){      session = sessionfactory.opensession();       query q = session.getnamedquery("findprofbyprofid");     q.setlong("id", id);     list<object> objet = q.list();     session.close();      return (arraylist<object>) objet;    } public void deleteprofbyprofid(int id){     profcrud pc= new profcrud();              session = sessionfactory.opensession();       session = hibernateutil.getsessionfactory().opensession();     transaction transaction = null;     try {         transaction = session.begintransaction();              prof c = (prof) pc.findprofbyprofid(id).get(0);                 session.delete(c);             transaction.commit();     } catch (hibernateexception e) {         transaction.rollback();         e.printstacktrace();     } {         session.close();     }         system.out.println(((prof) pc.findprofbyprofid(id).get(0)).getid()); } 

}

just before print opened session, started transaction , closed it. can't load object. don't know why worked if 1 clarify more i'll thankful.

session = sessionfactory.opensession();       session = hibernateutil.getsessionfactory().opensession();     transaction = session.begintransaction();          transaction.commit();     session.close(); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -