java - Managed objects not deleted by HQL query -


i'm working on inherited codebase of hibernate (3.3.2.ga - , since software should shipped rather there no time update) application in i'm trying delete objects database. after deleting objects via hql query objects can still retrieved hibernate session via findbyid method of (myeclipse generated) dao. there i'm missing objects disappear? need invalidate caches? after waiting seemingly random while (between 30 , 300 seconds) findbyid starts return null. objects use composite id. problem?

here code delete objects:

query query = objdao.getsession()             .createquery("delete obj i.id.uuid = ? , i.userid = ?"); query.setstring(0, obj.getuuid()); query.setinteger(1, currentuserid); objdao.getsession().begintransaction();  int numrows = query.executeupdate(); system.out.println("deleted " + numrows + " obj uuid " + obj.getuuid() + " (user: "             + currentuserid+ ")"); objdao.getsession().flush(); objdao.getsession().gettransaction().commit(); 

here code called afterwards retrieve objects database. expect return null not.

objdao.findbyid(new objectid(temp.getid(), temp.getuuid())) 

objdao.findbyid implemented such:

public obj findbyid(com.application.objectid id) {     obj instance = (obj) getsession() // returns org.hibernate.session     .get("com.application.obj", id);     return instance; } 

any appreciated!

not sure how getting session, recommend following:

getsessionfactory().opensession(); 

that ways new session , cached in previous session not returned.

cheers !!


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -