Tuesday, 15 September 2015

database - Getting class org.hibernate.TransactionException : nested transactions not supported -



database - Getting class org.hibernate.TransactionException : nested transactions not supported -

i'm trying retrieve info database through hibernate. i'm getting "org.hibernate.transactionexception : nested transactions not supported" exception when refresh jsp page. times i'm able result times i'm getting above exception. i'm using begintransaction() method 1 time in code. still getting exception. might root cause.

code : stringbuilder sb = new stringbuilder(); sb.append("{").append(status).append(ok).append(", ").append(results); sb.append("["); if(session == null){ homecoming geterrormsgjson("failed db session"); } seek { session.begintransaction(); listiterator iterator3 = session.createsqlquery(sqlstr).list().listiterator(); int t=0; while(iterator3.hasnext()){ object obj; object obj3[]=null; if((obj=iterator3.next()) instanceof biginteger){ sb.append("\""); sb.append(obj.tostring()); sb.append("\""); break; } else{ obj3 = (object[])iterator3.previous(); for(int i=0;i<obj3.length;i++){ sb.append("\""); sb.append(obj3[i].tostring()); sb.append("\""); if(t<obj3.length){ sb.append(","); } } } iterator3.next(); t++; } //session.gettransaction().commit(); sb.append("] }"); homecoming sb.tostring(); } grab (exception e) { //log.logerr(logc.js, logc.js_internal_err, "exception while getting db connection"); //out.println("exception while getting db connection"); //return geterrormsgjson(e.getclass().getname()+" : "+e.getmessage()); //return geterrormsgjson(e.getclass()+" "+e.getmessage()); //e.printstacktrace(); homecoming geterrormsgjson(e.getclass()+" : "+e.getmessage()); }

thanks in advance.

your not closing session, hence many transactions used not supported.

you can have block , close session in it.

try{ //your code }catch(exception e){ }finally{ session.close(); }

update after transactional exception resolved. getting genericjdbcexception. here creating sqlquery need specify entity entity table represents.

sqlquery query = session.createsqlquery(sql); query.addentity(employee.class); iterator itr = query.list().listiterator();

database hibernate jsp exception transactions

No comments:

Post a Comment