-->
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.  [ 2 posts ] 
Author Message
 Post subject: Session is closed with FullTestEntityManager
PostPosted: Fri Apr 04, 2014 11:36 am 
Newbie

Joined: Sun Nov 05, 2006 8:41 pm
Posts: 2
hi all -

I am trying to use FullTextEntityManager (and Spring) but getting a 'Session is closed' exception. I am able to query fine the first time, but the 2nd time, the exception is thrown. Here's my config:

Code:

@Service
@Transactional(readOnly = true, propagation=Propagation.SUPPORTS)
public class SearchServiceImpl extends BaseService implements SearchService {

    public List<StrainSearchResultsListItem> advancedSearch(Pageable page,String species) {
      return searchRepository.advancedSearch(page,   species);
   }


Code:

@Repository
@Transactional(readOnly = true)
public class SearchRepositoryImpl implements SearchRepository {

  @PersistenceContext
   public void setEntityManager(EntityManager entityManager) {
      this.entityManager = entityManager;
   }
   
   protected FullTextEntityManager getFullTextEntityManager() {
      
      if (fullTextEntityManager == null) {
         fullTextEntityManager = Search.getFullTextEntityManager(getEntityManager());
      }
      
      return fullTextEntityManager;
   }




As soon as I call:fullTextQuery.getResultList()
Code:

FullTextQuery fullTextQuery =
         getFullTextEntityManager()
            .createFullTextQuery(booleanQuery, Strain.class);
fullTextQuery.getResultList()



the second time the exception is thrown. Any help is appreciated.

thanks


Top
 Profile  
 
 Post subject: Re: Session is closed with FullTestEntityManager
PostPosted: Thu May 15, 2014 12:43 am 
Newbie

Joined: Thu May 15, 2014 12:30 am
Posts: 1
I was having the same problem and the only difference between my code and yours is that I didnt have the @Transactional(readOnly), I just had the @Repository to force Spring inject all dependencies (in this case EntityManager).
Without that annotation my search didnt works since the first one, but now after I add the @Transactional(readOnly) it fixed my problem....now I´m able to fire how many queries I want.

Just to you know I´m using Jpa + Hibernate, TransactionManager and C3P0 for connection pool.

What are you using ?


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

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.