-->
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: Hib+ZK: createQuery is not valid without active transaction
PostPosted: Wed Oct 29, 2008 4:38 am 
Newbie

Joined: Wed Oct 29, 2008 4:29 am
Posts: 1
Hi,

I'm using Hibernate together with ZK.

I get this error message (not valid without active transaction)
I'm doing 2 different ZK events, each running an own java thread, having a session and having non equal transactions.

I use HibernateSessionContextListener, as proposed in Small Talks - Hibernate + ZK.

in hibernate cfg file I use...
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="hibernate.current_session_context_class">thread</property>

First I do...
// Start Hibernate
SessionFactory sf = HibernateUtil.getSessionFactory(connectionInfo.getXDB_ConnectionInfo());
Session session = sf.getCurrentSession();
Transaction ta = session.beginTransaction();

After beginning a transaction...

I do a lot of
findAll, findById, do some processing of the database objects and write these to an XML structure for output...

and at last I do
ta.commit();

Now, if I call this sequence in ZK twice, both have an active transaction at first. But then I get this Hibernate exception, that the first started transaction is not active :-(

I don't know, how this transaction vanishes, I don't get any log message about this.

What am I doing wrong? Or is there something not possible with Hibernate built in TransactionFactory ...
Do I need a JTA Manager together with Apache Tomcat...

Lots of questions, few answers ...

best regards,
martin


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.