-->
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: Programming With Thread While Using Hibernate
PostPosted: Sun Feb 06, 2011 2:36 pm 
Newbie

Joined: Sun Feb 06, 2011 1:50 pm
Posts: 1
I am seeking assistencew with resolving an issue that has me baffled; maybe YOU can help!

The Givens:

- we have an application built using a Stripes/Spring/Hibernate frameworks environment

- our upload/import process is a long running process that can timeout, depending on how much data is being processed

- our data calls (crud) are developed using a few different programming techniques, all of which work (save for the occaisional timeout);
these include:

1) getHibernateTemplete().findBy*(); getHibernateTemplete().save(); etc.

2) Criteria query = getHibernateTemplate().getSessionFactory().getCurrentSession().createCriteria( ourClass.class );

3) Criteria query = getSession.createCriteria( ourClass.class );

Our Plan:

In order to resolve the timeout issue stated above, we decided to launch an asynchronous thread to do the intense processing while the user looks at a spinner page (which sleeps; wakes; checks status; sleeps again if still processing; redirects to a summary page if processing has completed).

What I did:

1.0) first, I moved the processing logic to a thread. This caused the following problem:
1.1) all statements of Type 2 (above) throw this exception:
No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

2.0) so, I changed all statements of Type 2 (above) to statements of Type 3 (above)
2.1) new problem: now process hangs waiting for JDBC connections

3.0) so, I added the following:
3.1) <prop key="hibernate.connection.release_mode">after_transaction</prop>
3.2) This seems to work, but I am unsure if these changes I made are "good" (ie, desirable) or not

4.0) I then tried using a DetachedCriteria for those statements of Type 2 (above); now, I get
4.1) failed to lazily initialize a collection of role: gov.epa.glnpo.data.Person.persTelephones, no session or session was closed

My Question:

1) which is the best format I should use for creating Criteria queries?
2) which of the changes (that I have described above) are good choices and which are not.
3) what am I missing from my environment that prevents my solution from working perfectly?

I appreciate you reading my post and for any insights you may provide

thanks

Chas


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.