-->
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: getNamedQuery() outside of transaction, is it possible?
PostPosted: Mon Sep 10, 2007 2:39 pm 
Newbie

Joined: Wed Aug 08, 2007 3:08 pm
Posts: 4
I am calling a Sybase stored proc (sp) that creates a temp table as part of its code. This sp cannot be called inside a transaction because it cannot rollback the temp table operations. Note: "dll in tran" is not an option in prod.

When I try to run the code below I get the following exception;
Quote:
org.hibernate.HibernateException: getNamedQuery is not valid without active transaction


Note: the code below works perfectly when I call a replacement sp without the temp table stuff (and uncomment the transaction begin and commit)

Code:
public List getCompanies(String orgId, String userId) {   
    List results = null;
    Session session = HibernateUtil.getCurrrentSession();
    //session.beginTransaction();
    results = session.getNamedQuery("getCompanyListSP")
   .setParameter("orgId",orgId)
   .setParameter("userId",userId)
   .list();
    //session.getTransaction().commit();
    session.close();
    ...
    return results;
}


I also have <property name="hibernate.connection.autocommit">true</property> set in hibernate.config.xml

Any ideas would be greatly appreciated.


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.