-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: ERROR JDBCTransaction:198 - Could not toggle autocommit
PostPosted: Mon Dec 18, 2006 4:51 pm 
Newbie

Joined: Mon Dec 18, 2006 4:07 pm
Posts: 2
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

[b]Hibernate version: [/b]
3.0

[b]Mapping documents:[/b]

[b]Code between sessionFactory.openSession() and session.close():[/b]

//HibernateUtil
static {
try {
// Create the SessionFactory from JNDI ; look in hibernate.cfg.xml
Configuration cfg = new Configuration();
sessionFactory = cfg.configure().buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}

public static Session getSession(String userId) throws HibernateException {
AuditLogInterceptor interceptor = new AuditLogInterceptor();
interceptor.setUserId(userId);
interceptor.setSessionFactory(sessionFactory);
Session s = sessionFactory.openSession(interceptor);
return s;
}

public static void closeSession(Session s) throws HibernateException {
if (s != null && s.isOpen())
s.close();
}

//calling session

public List getObjectsFromCriteria(Map expressionMap) throws Exception {
Session session = HibernateUtil.getSession(getUserName());
Transaction tx = session.beginTransaction();
Criteria crt = session.createCriteria(ReportedFactors.class);
if (expressionMap.containsKey("field4")) {
crt.add(Expression.eq("field4", expressionMap.get("field4")));
}
if (expressionMap.containsKey("field3")) {
crt.add(Expression.eq("field3", expressionMap.get("field3")));
}
if (expressionMap.containsKey("field2")) {
crt.add(Expression.eq("field2", expressionMap.get("field2")));
}
if (expressionMap.containsKey("field1")) {
crt.add(Expression.eq("key.current_date", expressionMap.get("field1")));
}
List objList = crt.list();
tx.commit();
HibernateUtil.closeSession(session);
return objList;
}


[b]Full stack trace of any exception that occurs:[/b]
5:44:23,458 ERROR JDBCTransaction:198 - Could not toggle autocommit
com.sybase.jdbc2.jdbc.SybSQLException: SET CHAINED command not allowed within multi-statement transaction.

at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2884)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:2206)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:220)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:203)
at com.sybase.jdbc2.jdbc.SybStatement.updateLoop(SybStatement.java:1702)
at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:1685)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:115)
at com.sybase.jdbc2.tds.Tds.setOption(Tds.java:1206)
at com.sybase.jdbc2.jdbc.SybConnection.setAutoCommit(SybConnection.java:986)
at weblogic.jdbc.wrapper.PoolConnection.setAutoCommit(PoolConnection.java:141)
at org.hibernate.transaction.JDBCTransaction.toggleAutoCommit(JDBCTransaction.java:194)
at org.hibernate.transaction.JDBCTransaction.commitAndResetAutoCommit(JDBCTransaction.java:142)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:115)
at com.fanniemae.iris.pfadiejb.reportedFactors.ReportedFactorsCommand.getProjectedObject(ReportedFactorsCommand.java:106)
at com.fanniemae.iris.pfadiejb.session.PfamiFacadeBean.getProjectedObject(PfamiFacadeBean.java:158)
at com.fanniemae.iris.pfadiejb.session.PfamiFacade_133g16_EOImpl.getProjectedObject(PfamiFacade_133g16_EOImpl.java:254)
at com.fanniemae.iris.pfadiejb.session.PfamiFacade_133g16_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:492)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:435)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:147)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:430)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:35)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)



[b]Name and version of the database you are using:[/b]
Sybase 12.5

[b]The generated SQL (show_sql=true):[/b]
Hibernate: select distinct this_.series as y0_, this_.agency_code as y1_ from cmoFactors..reported_factors this_ where this_.current_date=?


[b]Debug level Hibernate log excerpt:[/b]


Problems with Session and transaction handling? yes

Hibernate is doing commit properly but. It throws above exception, whenever we do any database access.
We are not using any stored procedure, we simple get the data from a table which has O/RM defined.

Read this: http://hibernate.org/42.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.